Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <locale>
- #include <windows.h>
- std::wofstream file;
- template <typename T1, typename T2, typename T3, typename T4>
- void diag_log(T1 arg1, T2 arg2, T3 arg3, T4 arg4)
- {
- file.imbue(std::locale(".utf-8", LC_ALL));
- file << arg1 << ' ' << arg2 << ' ' << arg3 << ' ' << arg4 << std::endl;
- }
- int wmain()
- {
- std::locale::global(std::locale(".utf-8",LC_ALL));
- file.open(L"D:\\file.txt");
- HANDLE hHeap = GetProcessHeap();
- LPVOID buffer = HeapAlloc(hHeap, HEAP_ZERO_MEMORY, 256);
- HWND hProgman = FindWindowW(L"Progman", NULL);
- HWND hBattery = FindWindowW(L"SystemTray_Main", NULL);
- GetWindowTextW(hProgman, (LPWSTR)buffer, 256 - sizeof(WCHAR)); // L"Program Manager"
- diag_log(L"HWND:", hProgman, L"Title:", (LPWSTR)buffer);
- GetWindowTextW(hBattery, (LPWSTR)buffer, 256 - sizeof(WCHAR)); // L"Индикатор батарей"
- diag_log(L"HWND:", hBattery, L"Title:", (LPWSTR)buffer);
- HeapFree(hHeap, NULL, buffer);
- file.close();
- return 0;
- }
- /*
- Вывод:
- HWND: 00020100 Title: Program Manager
- HWND: 000201E8 Title:
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement