winmain.c
上传用户:yinuo83
上传日期:2007-01-08
资源大小:36k
文件大小:1k
源码类别:

钩子与API截获

开发平台:

C/C++

  1. #include <windows.h>
  2. #include "resource.h"
  3. BOOL InstallMouseHook();
  4. BOOL UninstallMouseHook();
  5. BOOL CALLBACK DialogProc(HWND hDlg, UINT message,WPARAM wParam, LPARAM lParam);
  6. char *text,*text2;
  7. int WINAPI WinMain(HANDLE hInstance,HANDLE hPrevInstance,LPSTR lpszCmdLine,int nCmdShow)
  8. {
  9. DialogBox(hInstance,MAKEINTRESOURCE(IDD_DIALOG1),NULL,DialogProc);
  10. return 0;
  11. }
  12. BOOL CALLBACK DialogProc(HWND hDlg, UINT message,WPARAM wParam, LPARAM lParam)
  13. {
  14. HDC hdc;
  15. PAINTSTRUCT paintst;
  16. HANDLE hmapfile;
  17. switch ( message )
  18. {
  19. case WM_INITDIALOG:
  20. SetWindowText(hDlg,"myciba");
  21. hmapfile=CreateFileMapping(NULL, 
  22. NULL, 
  23. PAGE_READWRITE, 
  24. 0, 
  25. 128, 
  26. "textbuf" 
  27. ); 
  28. text=(char *)MapViewOfFile( hmapfile,
  29.                          FILE_MAP_ALL_ACCESS,
  30.  0,
  31.  0,
  32.  128
  33.  );
  34. SetWindowPos( hDlg,HWND_TOPMOST,0,0,200,200,SWP_SHOWWINDOW);
  35. InstallMouseHook();
  36. break;
  37. case WM_PAINT:
  38. hdc=BeginPaint(hDlg,&paintst);
  39.     //ZhouTextOutA(hdc,10,50,"abcde",5);
  40. EndPaint(hDlg,&paintst);
  41. break;
  42. case 65000:
  43. SetWindowText(GetDlgItem(hDlg,1000),text);
  44. //PostMessage(GetDlgItem(hDlg,IDC_LIST1),LB_ADDSTRING,0,text);
  45. break;
  46. case WM_COMMAND:
  47. //UninstallMouseHook();
  48. exit(0);
  49. break;
  50. case WM_CLOSE:
  51. //UninstallMouseHook();
  52. break;
  53. default:
  54. break;
  55. }
  56. return FALSE;
  57. }