BOOL CProcessInfo::GetProcessList(LPCTSTR lpszOutputFileName)
{
char szOutString[BUFSIZE];
HANDLE hProcessSnap = NULL;
    BOOL bRet      = FALSE;
    PROCESSENTRY32 pe32      = {0};

CWriteToFile* pFile = new CWriteToFile();
   
    hProcessSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);

    if (hProcessSnap == INVALID_HANDLE_VALUE)
        return (FALSE);

    pe32.dwSize = sizeof(PROCESSENTRY32);

    if (Process32First(hProcessSnap, &pe32))
    {
do
{
//ProcessName
wsprintf(szOutString, "%s[#]%s[#]^1^[#][%%]0[%%]%s[%%]0[%%][$]",
PROCESSINFO, pe32.szExeFile, pe32.szExeFile);
pFile->WriteRecord(szOutString,lpszOutputFileName);
//ProcessID
wsprintf(szOutString, "%s[#]%s[#]^5U^[#][%%]1[%%]%d[%%]1[%%][$]",
PROCESSINFO, pe32.szExeFile, pe32.th32ProcessID);
pFile->WriteRecord(szOutString,lpszOutputFileName);
//ParentID
wsprintf(szOutString, "%s[#]%s[#]^5V^[#][%%]1[%%]%d[%%]2[%%][$]",
PROCESSINFO, pe32.szExeFile, pe32.th32ParentProcessID);
pFile->WriteRecord(szOutString,lpszOutputFileName);
//ThreadCount
wsprintf(szOutString, "%s[#]%s[#]^5W^[#][%%]0[%%]%d[%%]3[%%][$]",
PROCESSINFO, pe32.szExeFile, pe32.cntThreads);
pFile->WriteRecord(szOutString,lpszOutputFileName);
//PriorityClassBase
wsprintf(szOutString, "%s[#]%s[#]^5X^[#][%%]0[%%]%d[%%]4[%%][$]",
PROCESSINFO, pe32.szExeFile, pe32.pcPriClassBase);
pFile->WriteRecord(szOutString,lpszOutputFileName);
        }
        while (Process32Next(hProcessSnap, &pe32));
        bRet = TRUE;
    }
    else
        bRet = FALSE;

    CloseHandle (hProcessSnap);


delete pFile;

    return (bRet);
}

?
//枚举进程,找寻NOTEPAD.exe
int CTestHookDlg::EnumProcess()
{
	PROCESSENTRY32 pe;
	HANDLE hSnapshot;
	DWORD dRet=0;		
			//遍历进程		
			hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);
			pe.dwSize = sizeof(PROCESSENTRY32);
			if( !Process32First(hSnapshot,&pe) )
				return dRet;
			do{
				pe.dwSize = sizeof(PROCESSENTRY32);
				if( Process32Next(hSnapshot,&pe)==FALSE )
					break;
				if(stricmp(pe.szExeFile,"NOTEPAD.exe") == 0){
					dRet=pe.th32ProcessID;
				}
			} while(1);
			CloseHandle(hSnapshot);
	return dRet;
}

DWORD CXXXXXDlg::FindAppProcessID()
{
HANDLE handle=::CreateToolhelp32Snapshot(TH32CS_SNAPALL,0);
PROCESSENTRY32 Info;
Info.dwSize = sizeof(PROCESSENTRY32);
if(::Process32First(handle,&Info))
{
do{
CString ss=Info.szExeFile;
if(!ss.CompareNoCase(m_strSoft+".exe"))
{
::CloseHandle(handle);
return Info.th32ProcessID;
}
}
while(::Process32Next(handle,&Info));
::CloseHandle(handle);
}
return -1;
}