Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

hi,

i have a problem with stopping windows to shutdown , i founded some code

 

 private int WM_QUERYENDSESSION  = 0x11;
 private int WM_CANCELMODE  = 0x1F;
 
 protected override void WndProc(ref Message m)
 {
       if (m.Msg == WM_QUERYENDSESSION)
        {
          Message x = new Message();
   		
               x.Msg = WM_CANCELMODE;
   		base.WndProc(x);
        

        }
        else
        {
          base.WndProc(m);
        }
 }
 

 

but this code doesn't work ,,, windows is still shuting down ( logging off or restart )!

 

Any ideas?

tx...

Some people are wise and some are other-wise.
Posted
  Quote
Why are you trying to do this? And does it somehow relate to COM Interop issues like Automating MS Office Applications?

 

i need to know when/if that happens , because i want to close my application properly!

Some people are wise and some are other-wise.
Posted

Ok, I think I'm starting to get it... And I'm probably not the right guy to help here. But guessing a bit: Are you saying that when Windows Shuts down you want to be able to hold up the process long enough so that you can shut down your resources properly? The 20 seconds or so default is not sufficient?

 

I really don't know that this process can be prevented, but I'm not really one to know such things...

 

Can I ask what resources you are trying to shut down? What Applications are you Auttomating/Controlling? Are they MS Office Applications?

Posting Guidelines

 

Avatar by Lebb

Posted (edited)

Problem "solved"

 

ok, i found the problem ,,code above works fine , but if you try to ask user with MessageBox "Are you sure" for example then code above doesn't work,, so i'm traping WM_ENDSESSION and immidetly after that i'm sending WM_CANCELMODE.

If user click "Yes" for example :) i'm calling other class that shutdown the computer...

 

:cool: :D

Edited by sizer
Some people are wise and some are other-wise.
Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...