fork download
  1. #include "stdafx.h"
  2.  
  3. int _cdecl _tmain (int argc, TCHAR *argv[])
  4. {
  5. if (::RegisterHotKey(
  6. NULL,
  7. 1,
  8. MOD_WIN| MOD_CONTROL | MOD_NOREPEAT,
  9. VK_F1)) //0x42 is 'b'
  10. {
  11. ::_tprintf(_T("Hotkey registered, using MOD_NOREPEAT flag\n"));
  12. }
  13. else
  14. {
  15. DWORD errorMessageID = ::GetLastError();
  16.  
  17. LPTSTR messageBuffer = NULL;
  18. ::FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
  19. NULL, errorMessageID, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)&messageBuffer, 0, NULL);
  20.  
  21.  
  22. ::_tprintf(_T("Error: %s\n"), messageBuffer);
  23.  
  24. ::LocalFree(messageBuffer);
  25. }
  26.  
  27. MSG msg = {0};
  28.  
  29. while (::GetMessage(&msg, NULL, 0, 0) != 0)
  30. {
  31. if (msg.message == WM_HOTKEY)
  32. {
  33. ::_tprintf(_T("WM_HOTKEY received\n"));
  34. }
  35. }
  36.  
  37. return 0;
  38. }
  39.  
  40.  
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty