9 void (__stdcall *SetHook)(HINSTANCE hModule);
10 void (__stdcall *RemoveHook)();
12 LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
16 static HWND hStartButton;
17 static HWND hEndButton;
25 switch(LOWORD(wParam)) {
37 hStartButton = CreateWindow(
38 TEXT("BUTTON"), TEXT("Start"),
39 WS_CHILD | WS_VISIBLE |BS_PUSHBUTTON,
40 0, 0, 100, 50, hWnd, (HMENU)BUTTON_ID1,
41 ((LPCREATESTRUCT)(lParam))->hInstance, NULL);
42 hEndButton = CreateWindow(
43 TEXT("BUTTON"), TEXT("End"),
44 WS_CHILD | WS_VISIBLE |BS_PUSHBUTTON,
45 100, 0, 100, 50, hWnd, (HMENU)BUTTON_ID2,
46 ((LPCREATESTRUCT)(lParam))->hInstance, NULL);
48 return DefWindowProc(hWnd, msg, wParam, lParam);
51 int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
52 PSTR lpCmdLine, int nCmdShow)
54 hModule = LoadLibrary("mousehook_lib.dll");
56 fprintf(stderr, "not found mousehook_lib.dll");
60 SetHook = (void (__stdcall *)(HINSTANCE)) (HINSTANCE)GetProcAddress(hModule, "SetHook");
61 RemoveHook = (void (__stdcall *)()) (HINSTANCE)GetProcAddress(hModule, "RemoveHook");
67 winc.style = CS_HREDRAW | CS_VREDRAW;
68 winc.lpfnWndProc = WndProc;
69 winc.cbClsExtra = winc.cbWndExtra = 0;
70 winc.hInstance = hInstance;
71 winc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
72 winc.hCursor = LoadCursor(NULL, IDC_ARROW);
73 winc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
74 winc.lpszMenuName = NULL;
75 winc.lpszClassName = TEXT("mousehook");
77 if(!RegisterClass(&winc)) {
78 fprintf(stderr, "RegisterClass\n");
83 TEXT("mousehook"), TEXT("Kitty on your lap"),
84 WS_OVERLAPPEDWINDOW | WS_VISIBLE,
85 CW_USEDEFAULT, CW_USEDEFAULT,
87 NULL, NULL, hInstance, NULL);
90 fprintf(stderr, "CreateWindow\n");
94 while(GetMessage(&msg, NULL, 0, 0)) {
95 TranslateMessage(&msg);
96 DispatchMessage(&msg);