visual c++ - How to get names of all opened windows in my system using a vc++ application? -


I am trying to solve a problem, to display names of currently open windows.

I am using vc ++ (dialog-based apps).

GetWindow The API to go through the handle of the displayed windows. Use the GetWindowText API to get caption title (if it has one).

  hwnd wnd = :: GetWindow (this-> GetSafeHWND (), GW_HWNDFIRST); If (! Wnd) {return; } CString csWindows = ""; Doing {CString csText; :: GetWindowText (wnd, csText.GetBuffer (MAX_PATH), MAX_PATH); CsText.ReleaseBuffer (); If (! CsText.IsEmpty ()) {csWindows + = csText + "\ n"; }} While (wnd = :: GetWindow (wnd, GW_HWNDNEXT)); Afs Message Box (CSWindo);   

The above code should work. If you only want a visible window, use the :: IsWindowVisible API to check it.

Update:

An application that can be referred to GetWindow caught in an eternal loop or to destroy a window This task calls for execution of risk. Quoted from

/ P>

Comments