Link to home
Start Free TrialLog in
Avatar of chowdary010899
chowdary010899

asked on

close all

I want to close all windows on the desktop. either they are minimised or maximised state i want to close all windows. which functions i have to use??
give me sample code..

thank u for answer..
ASKER CERTIFIED SOLUTION
Avatar of Vinayak Kumbar
Vinayak Kumbar

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Vinayak Kumbar
Vinayak Kumbar

Hi,

If U want U can customise the function EnumWindowsProc(),

U can get the windowtext using hwnd, then compare it to close some of the windows only.(definitly U dont want to close Ur own application window right?. Then get the window text using ::GetWindowText() and if it matches with Urs then dont post that message.)

Try it out.
Avatar of chowdary010899

ASKER

Thanx for your response.. Whatever ur advise is correct but My application won't show any window on the desktop..
It will run as a service..

 one more thing.. If i use enumwindows function it is showing system shutdown dialog, after closing the all applications.it should not show that dialog and should not close my application, But it should close all others.. please get me solution..If u give ur email i will be happy.. :o)

Thanx for ur answer.. Mr Vinexpert..
Thanx for your response.. Whatever ur advise is correct but My application won't show any window on the desktop..
It will run as a service..

 one more thing.. If i use enumwindows function it is showing system shutdown dialog, after closing the all applications.it should not show that dialog and should not close my application, But it should close all others.. please get me solution..If u give ur email i will be happy.. :o)

Thanx for ur answer.. Mr Vinexpert..
Thanx for your response.. Whatever ur advise is correct but My application won't show any window on the desktop..
It will run as a service..

 one more thing.. If i use enumwindows function it is showing system shutdown dialog, after closing the all applications.it should not show that dialog and should not close my application, But it should close all others.. please get me solution..If u give ur email i will be happy.. :o)

Thanx for ur answer.. Mr Vinexpert..
Hi,

I was waiting for Ur response. Okay, It will show that shut down message as program manager is also closed.

So After calling ::GetWindowText(), store the text in CString variable say l_strText and  if it is the program manager, then dont close it.

U may have to do something like this.
if(l_strText.Find("Program") == -1)
      PostMessage(hwnd, WM_CLOSE, 0, 0);

Do the same for Ur application also. Say if Ur application has the window text as "EnmWinws" (usually the application will have the title as the project itself), then
if((l_strText.Find("Program") == -1) && (l_strText.Find("EnmWinws") == -1)
      PostMessage(hwnd, WM_CLOSE, 0, 0);

Try it out.

Pls Note: One click on the Submit button is sufficient.(why               thrice?. Sorry I am not serious)

Hi,

Give me Ur email ID, I will send U the sample workspace.
My mail id is ksuneel@hotmail.com cyber friend..
:o)

thank u...
Hi,

I have sent the zipped workspace to Ur ID. Check it out.
If there are any probs, tell me.

Good Luck.
Hi VinExpert :)

Thank u friend...Its enough for me. if i want any help i will mail u or i will place question in this..

CHOWDARY