Advertisement
SkidScripts

Untitled

Feb 26th, 2022
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.15 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <locale>
  4. #include <windows.h>
  5.  
  6. std::wofstream file;
  7.  
  8. template <typename T1, typename T2, typename T3, typename T4>
  9. void diag_log(T1 arg1, T2 arg2, T3 arg3, T4 arg4)
  10. {
  11.     file.imbue(std::locale(".utf-8", LC_ALL));
  12.     file << arg1 << ' ' << arg2 << ' ' << arg3 << ' ' << arg4 << std::endl;
  13. }
  14.  
  15. int wmain()
  16. {
  17.     std::locale::global(std::locale(".utf-8",LC_ALL));
  18.  
  19.     file.open(L"D:\\file.txt");
  20.  
  21.     HANDLE hHeap = GetProcessHeap();
  22.     LPVOID buffer = HeapAlloc(hHeap, HEAP_ZERO_MEMORY, 256);
  23.  
  24.     HWND hProgman = FindWindowW(L"Progman", NULL);
  25.     HWND hBattery = FindWindowW(L"SystemTray_Main", NULL);
  26.  
  27.     GetWindowTextW(hProgman, (LPWSTR)buffer, 256 - sizeof(WCHAR)); // L"Program Manager"
  28.     diag_log(L"HWND:", hProgman, L"Title:", (LPWSTR)buffer);
  29.  
  30.     GetWindowTextW(hBattery, (LPWSTR)buffer, 256 - sizeof(WCHAR)); // L"Индикатор батарей"
  31.     diag_log(L"HWND:", hBattery, L"Title:", (LPWSTR)buffer);
  32.  
  33.     HeapFree(hHeap, NULL, buffer);
  34.     file.close();
  35.     return 0;
  36. }
  37.  
  38. /*
  39. Вывод:
  40. HWND: 00020100 Title: Program Manager
  41. HWND: 000201E8 Title:
  42. */
  43.  
  44.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement