I want to loop trough all the windows running and get their hwnd and convert it to an int. Here is the function I have that attempts to do this (very similar to code i have previously posted):
The problem is that all the hwnds are the same (1952) and using hModule doesn't work either. I am pretty sure that hProcess is the hwnd. All the process names work fine and the ListView works.Code:int getProcesses(HWND hwnd) { HMODULE hModule; char szProcessName[MAX_PATH] = {0}; DWORD dwProcesses[1024], cbNeeded, cProcesses; unsigned int i; char PIDbuf[128]; if (!EnumProcesses(dwProcesses, sizeof(dwProcesses), &cbNeeded)) return -1; cProcesses = cbNeeded / sizeof(DWORD); for (i = 0; i < cProcesses; i++) if(dwProcesses[i] != 0) { HANDLE hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, dwProcesses[i]); if (NULL != hProcess) { strcpy(szProcessName, "System"); if (EnumProcessModules(hProcess, &hModule, sizeof(hModule), &cbNeeded)) { GetModuleBaseName(hProcess, hModule, szProcessName, sizeof(szProcessName)/sizeof(CHAR)); } sprintf(PIDbuf, "%d : %s", (int)hProcess, szProcessName); SendDlgItemMessage(hwnd, 1000, LB_ADDSTRING, 0, (LPARAM)PIDbuf); } CloseHandle(hProcess); } return cProcesses; }



LinkBack URL
About LinkBacks



