14/03/2008, 13:52
|
| | Fecha de Ingreso: marzo-2008
Mensajes: 22
Antigüedad: 16 años, 9 meses Puntos: 1 | |
Re: Virus en C /*
No se exactamente que es lo que necesitas,
pero te envio esto, espero que te sirva.
No lo consideraría un virus, pero si un programa muy molesto.
Para cerrarlo deberas acerlo a traves del administrador de tareas
*/
#include <tchar.h>
#include <windows.h>
BOOL g_bHide = FALSE;
HWND g_hWndMain = NULL;
TCHAR g_szAppName[] = _T("");
TCHAR g_szClassName[] = _T("ClassName");
TCHAR g_szWindowMessage[] = _T("Este es un mensage");
#define TIMER_ID 1
#define TIMER_ELAPSE 250
#define WINDOW_WIDTH 250
#define WINDOW_HEIGHT 150
LRESULT CALLBACK WndProcMain(HWND hWnd, UINT uiMessage, WPARAM wParam, LPARAM lParam)
{
switch(uiMessage)
{
case WM_CREATE:
SetTimer(hWnd, TIMER_ID, TIMER_ELAPSE, 0);
break;
case WM_DESTROY:
KillTimer(hWnd, TIMER_ID);
PostQuitMessage(0);
break;
case WM_TIMER:
g_bHide ^= TRUE;
if(g_bHide)
ShowWindow(hWnd, SW_HIDE);
else
{
ShowWindow(hWnd, SW_SHOW);
SetForegroundWindow(hWnd);
}
break;
case WM_PAINT:
{
RECT rc;
PAINTSTRUCT ps;
BeginPaint(hWnd, &ps);
GetClientRect(hWnd, &rc);
FillRect(ps.hdc, &rc, GetSysColorBrush(COLOR_BTNFACE));
DrawText(ps.hdc, g_szWindowMessage, lstrlen(g_szWindowMessage), &rc, DT_CENTER | DT_VCENTER | DT_SINGLELINE);
EndPaint(hWnd, &ps);
}
break;
case WM_NCHITTEST:
return 0;
default:
return DefWindowProc(hWnd, uiMessage, wParam, lParam);
}
return 0;
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
{
MSG msg;
WNDCLASSEX wcex;
wcex.hInstance = hInstance;
wcex.lpfnWndProc = WndProcMain;
wcex.lpszMenuName = NULL;
wcex.lpszClassName = g_szClassName;
wcex.style = CS_DBLCLKS;
wcex.cbSize = sizeof(WNDCLASSEX);
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hIcon = NULL;
wcex.hIconSm = NULL;
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
wcex.hbrBackground = NULL;
if(!RegisterClassEx(&wcex))
{
return 0;
}
LONG nX;
LONG nY;
LONG nScreenCX = GetSystemMetrics(SM_CXSCREEN);
LONG nScreenCY = GetSystemMetrics(SM_CYSCREEN);
nX = (nScreenCX / 2) - (WINDOW_WIDTH / 2);
nY = (nScreenCY / 2) - (WINDOW_HEIGHT / 2);
g_hWndMain = CreateWindowEx(0, g_szClassName, g_szAppName,
0, nX, nY, WINDOW_WIDTH, WINDOW_HEIGHT, HWND_DESKTOP, NULL, hInstance, NULL);
if(g_hWndMain == NULL)
{
return 0;
}
while(GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
} |