Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++/MFC
hi everybody
have a good time
 
i use visual c++ and i want to know how can i get a list that includes names of opened windows in Operating system?
Care that we don't know count of them.
 
for example:
 
i open the "Calculator", "Computer", "Personalization", ... windows.
finally i want to give below list with API functions:
 
Calculator
Computer
Personalization
.
.
.
Posted 23-Dec-12 3:12am
Edited 23-Dec-12 6:21am
CPallini333.2K
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

As Richard already suggested, use EnumWindows function. Then in the callback implementation (see EnumWindowsProc callback function[^] at MSDN), call GetWindowText[^], see this thread[^].
  Permalink  
Comments
Richard MacCutchan at 23-Dec-12 11:35am
   
And a 5 for all the extra information.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

The EnumWindows function[^] will get you what you want.
  Permalink  
Comments
CPallini at 23-Dec-12 11:20am
   
5.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

this code works:
 
BOOL EnumWindowsProc(HWND hWnd, long lParam)
{
         char Buff[255], NameOfClass[255];
		 
         GetWindowTextA(hWnd, Buff, 254);           // titlul ferestrei
		 
         GetClassNameA(hWnd, NameOfClass, 254);  // clasa
         //adauga in lista:
         
         return TRUE;
}
 
void CEnumWindowsDlg::OnBnClickedButton1()
{
WNDENUMPROC w;
EnumWindows((WNDENUMPROC)EnumWindowsProc, 0);
 

}
 
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 8,478
1 OriginalGriff 6,516
2 Peter Leow 3,567
3 Zoltán Zörgő 3,351
4 Richard MacCutchan 2,397


Advertise | Privacy | Mobile
Web01 | 2.8.150123.1 | Last Updated 23 Dec 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100