HWND hwndList = GetDlgItem (hwnd, IDC_PROCESSMODULELIST );
SetWindowRedraw (hwndList, FALSE );
ComboBox_ResetContent (hwndList );
CToolhelp thProcesses (TH32CS_SNAPPROCESS );
PROCESSENTRY32 pe = {sizeof (pe )};
BOOL fOk = thProcesses. ProcessFirst (& pe );
For (; fOk = thProcesses. ProcessNext (& pe )){
TCHAR sz [1024];
// Place the process name (without its path) & ID in the list
PCTSTR pszExeFile = _ tcsrchr (pe. szExeFile, TEXT ('//'));
If (pszExeFile = NULL) pszExeFile = pe. szExeFile;
Else pszExeFile ++; // Skip over the slash
Wsprintf (sz, TEXT ("% s (0x % 08X)"), pszExeFile, pe. th32ProcessID );
Int n = ComboBox_AddString (hwndList, sz );
// Associate the process ID with the added item
ComboBox_SetItemData (hwndList, n, pe. th32ProcessID );
}
ComboBox_SetCurSel (hwndList, 0); // Select the first entry
// Simulate the user selecting this first item so that
// Results pane shows something interesting
FORWARD_WM_COMMAND (hwnd, IDC_PROCESSMODULELIST,
HwndList, CBN_SELCHANGE, SendMessage );
SetWindowRedraw (hwndList, TRUE );
InvalidateRect (hwndList, NULL, FALSE );