Process32First 返回FALSE的原因

一般情况下是不会返回FALSE的,如果发生了,请检查:

1:系统为UNICODE的,一定要设置PROCESSENTRY32的dwSize为sizeof(PROCESSENTRY32)即可。。

m_list.DeleteAllItems();
	// 开始添加
	PROCESSENTRY32  processEntry32;
	processEntry32.dwSize = sizeof(PROCESSENTRY32);
	HANDLE hSnapshot =  ::CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
	BOOL bResult = ::Process32First(hSnapshot, &processEntry32);
	while(bResult)
	{
		
		CString strProcessName, strProcessId;
		strProcessName.Format(L"%s", processEntry32.szExeFile);
		strProcessId.Format(L"0x%x", processEntry32.th32ProcessID);
		int iRow = m_list.InsertItem(0, strProcessName);
		m_list.SetItemText(iRow, 1, strProcessId);

		bResult = Process32Next(hSnapshot, &processEntry32);
	}


 

Process32First 返回FALSE的原因_第1张图片

你可能感兴趣的:(Process32First 返回FALSE的原因)