下面的代码应该工作:
INT iIndex = 1;
HWND hwnd = ::GetWindow( ::GetDesktopWindow(), GW_CHILD | GW_HWNDFIRST );
while( hwnd ) {
CString sCaption;
::GetWindowText(hwnd, sCaption.GetBuffer(256), 255);
sCaption.ReleaseBuffer();
//DWORD dwProcessID = 0L;
//::GetWindowThreadProcessId(hwnd, &dwProcessID);
//CString sExePath;
//::GetModuleFileName((HMODULE)dwProcessID, sExePath.GetBuffer(MAX_PATH), MAX_PATH);
//sExePath.ReleaseBuffer();
if ( sCaption.Find(_T("c:\\")) != -1 ) {
// found you!
}
hwnd = ::GetWindow( hwnd, GW_HWNDNEXT );
}