I was just trying to undo some old code from Windows XP that generates a list of all running processes, but it failed in Windows 7. Before proceeding, here is the code:
#include <windows.h> #include <tlhelp32.h> int main() { HANDLE hSnap, hTemp; PROCESSENTRY32 pe; hSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); if(Process32First(hSnap, &pe)) { do { ... } } while(Process32Next(hSnap, &pe)); } ... }
I checked which function failed, and it turned out to be Process32First. GetLastError () returned 24: "ERROR_BAD_LENGTH" I cannot understand what the problem is. Any suggestions?
source share