Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. // Create an instance of HookProc.
  2. StartHookProcedure = new CallBack(StartHookProc);
  3. IntPtr desktop = FindWindowEx(
  4. IntPtr.Zero, IntPtr.Zero, "Progman", null);
  5. uint procId = 0;
  6. uint threadId = GetWindowThreadProcessId(desktop, out procId);
  7. Process process = Process.GetCurrentProcess();
  8. ProcessModule module = process.MainModule;
  9.  
  10. IntPtr hModule = GetModuleHandle(null); // get my module handle...
  11. //IntPtr start = FindWindowEx(desktop, IntPtr.Zero, "Button", null);
  12.  
  13. hHook = SetWindowsHookEx(WH_GETMESSAGE,
  14. StartHookProcedure, hModule, (int)threadId);
  15. //If the SetWindowsHookEx function fails.
  16. if (hHook == 0)
  17. {
  18. int err = Marshal.GetLastWin32Error();
  19. MessageBox.Show("SetWindowsHookEx Failed" + err.ToString());
  20. return;
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement