1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
|
WX_DECLARE_OBJARRAY(xApp, apps);
WX_DEFINE_OBJARRAY(apps);
void HexFrm::getApps(bool user) {
#ifdef WIN32
if (appWait > 500 || user == true) {
// variable creation
appWait = 0; wxString s; xApp a; char* t; WPARAM tl; HWND hwnd; HANDLE ht;
PROCESSENTRY32 pe32; THREADENTRY32 te32 = {0}; GUITHREADINFO ti32;
pe32.dwSize = sizeof(PROCESSENTRY32); te32.dwSize = sizeof(THREADENTRY32);
HANDLE hp = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
// main code
hexLBSoftware->Clear();
if (hp != INVALID_HANDLE_VALUE && Process32First(hp, &pe32)) {
do {
ht = CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD, pe32.th32ProcessID);
Thread32First(ht, &te32);
do {
GetGUIThreadInfo(te32.th32ThreadID,&ti32) != 0;
hwnd = GetWindow(ti32.hwndActive, GW_OWNER);
if (hwnd == NULL)
hwnd = ti32.hwndActive;
tl = SendMessage(hwnd, WM_GETTEXTLENGTH, 0, 0);
if (tl > 0) {
SendMessage(hwnd, WM_GETTEXT, tl, (LPARAM)&t);
s.Printf("%s: %s", pe32.szExeFile, t);
break;
} s.Printf(pe32.szExeFile);
} while (Thread32Next(ht,&te32));
if (s != "") {
hexLBSoftware->Append(s);
//apps->Add((xApp)a, 1);
}
} while (Process32Next(hp, &pe32));
}
/*
if (pe32.th32ProcessID != 0) {
apps[i].id = pid;
apps[i].exe.Printf(pe32.szExeFile);
GetWindowText(ti32->hwndActive,t,sizeof(LPTSTR));
apps[i].name.Printf(t);
apps[i].hwnd = ti32->hwndActive;
s = apps[i].exe << " - " << apps[i].name;
hexLBSoftware->Append(s); i++;
}
}*/
CloseHandle(ht); CloseHandle(hp);
} else { appWait++; }
#endif
}
|