我想枚举进程的路径,然后添加到listCtrl中,可是编译成功但是运行的时候出现错误 typedef BOOL (_stdcall *ENUMPROCESSMODULES)(HANDLE hProcess,HMODULE *lpModule,DWORD cb,LPDWORD lpNeeded);
typedef DWORD (_stdcall *GETMODULEFILENAMEEX)(HANDLE hProcess,HMODULE hModule,LPTSTR lpFileName,DWORD nSize);
HANDLE hSnap;
int i = 0;
HANDLE hProcess;
HINSTANCE hPsapi;
HMODULE hModule;
DWORD Needed;
char FileName[MAX_PATH];
hPsapi = LoadLibrary("PSAPI.DLL");
ENUMPROCESSMODULES pEnumProcessModules = (ENUMPROCESSMODULES)GetProcAddress(hPsapi,"EnumProcessModules");
GETMODULEFILENAMEEX pGetModuleFileNameEx = (GETMODULEFILENAMEEX)GetProcAddress(hPsapi,"GetModuleFileNameEx");
hSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);
if(hSnap == INVALID_HANDLE_VALUE)
{
MessageBox("Create Snap failed");
return;
}
PROCESSENTRY32 PInfo;
PInfo.dwSize = sizeof(PROCESSENTRY32);
BOOL FindSuccess = Process32First(hSnap,&PInfo);
while(FindSuccess)
{
hProcess = OpenProcess(PROCESS_ALL_ACCESS,FALSE,PInfo.th32ProcessID);
pEnumProcessModules(hProcess,&hModule,sizeof(hModule),&Needed);
pGetModuleFileNameEx(hProcess,hModule,FileName,sizeof(FileName));
m_list.InsertItem(i,FileName);
FindSuccess = Process32Next(hSnap,&PInfo);
i++;
}
CloseHandle(hProcess);
CloseHandle(hSnap);
}
[培训]内核驱动高级班,冲击BAT一流互联网大厂工作,每周日13:00-18:00直播授课