Created
August 9, 2018 13:23
-
-
Save Kiterai/6f4315269bc7cb331bafa720c23b4c85 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DWORD GetMainThread(DWORD Pid) | |
{ | |
struct | |
{ | |
const DWORD Pid; | |
DWORD Tid; | |
} tmpDat = {Pid, 0}; | |
EnumWindows( | |
[](HWND hWnd, LPARAM lp) -> BOOL | |
{ | |
DWORD WndPid; | |
DWORD tmpTid = GetWindowThreadProcessId(hWnd, &WndPid); | |
auto pTmpDat = reinterpret_cast<decltype(tmpDat)*>(lp); | |
if ( | |
WndPid == pTmpDat->Pid && | |
GetWindow(hWnd, GW_OWNER) == NULL && | |
IsWindowVisible(hWnd)) | |
{ | |
pTmpDat->Tid = tmpTid; | |
return FALSE; | |
} | |
else | |
{ | |
return TRUE; | |
} | |
}, | |
reinterpret_cast<LPARAM>(&tmpDat)); | |
return tmpDat.Tid; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment