os_

Media Key Test

os_
Jul 19th, 2018
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.91 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include "Windows.h"
  3. #include <iostream>
  4. #include <string>
  5. using namespace std;
  6.  
  7. int _cdecl _tmain(int argc, TCHAR *argv[])
  8. {
  9.     for (int i = 0xB0; i <= 0xB3; i++)
  10.         if (RegisterHotKey(NULL, 1, NULL, i))
  11.             printf("Hotkey 0x%02X registered\n", i);
  12.  
  13.     int count = 0;
  14.     MSG msg = { 0 };
  15.     while (GetMessage(&msg, NULL, 0, 0)) {
  16.         count++;
  17.  
  18.         char* name = (char*)malloc(5);
  19.         switch (msg.lParam) {
  20.             case 0xB00000: strcpy_s(name, 5, "FORW"); break;
  21.             case 0xB10000: strcpy_s(name, 5, "BACK"); break;
  22.             case 0xB20000: strcpy_s(name, 5, "STOP"); break;
  23.             case 0xB30000: strcpy_s(name, 5, "PLAY"); break;
  24.         }
  25.  
  26.         printf("==========================\n");
  27.         printf("Count:   %d\n", count);
  28.         printf("message: 0x%02X\n", msg.message);
  29.         printf("wParam:  0x%02X\n", msg.wParam);
  30.         printf("lParam:  0x%02X\n", msg.lParam);
  31.         printf("Media:   %s\n", name);
  32.         free(name);
  33.     }
  34.     return 0;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment