sizer Posted October 5, 2004 Posted October 5, 2004 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... Quote Some people are wise and some are other-wise.
Mike_R Posted October 6, 2004 Posted October 6, 2004 Why are you trying to do this? And does it somehow relate to COM Interop issues like Automating MS Office Applications? Quote Posting Guidelines Avatar by Lebb
sizer Posted October 6, 2004 Author Posted October 6, 2004 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! Quote Some people are wise and some are other-wise.
Mike_R Posted October 6, 2004 Posted October 6, 2004 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? Quote Posting Guidelines Avatar by Lebb
sizer Posted October 6, 2004 Author Posted October 6, 2004 no, it is backup tool! Quote Some people are wise and some are other-wise.
sizer Posted October 6, 2004 Author Posted October 6, 2004 (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 October 6, 2004 by sizer Quote Some people are wise and some are other-wise.
Mike_R Posted October 6, 2004 Posted October 6, 2004 Ok, glad you got it! :) (And sorry I couldn't help more. :() Quote Posting Guidelines Avatar by Lebb
sizer Posted October 6, 2004 Author Posted October 6, 2004 Quote Ok, glad you got it! :) (And sorry I couldn't help more. :() no problem ;) Quote Some people are wise and some are other-wise.
Recommended Posts