PROKA Posted September 4, 2003 Posted September 4, 2003 How can I shut down the computer ? ExitWindowsEx api doesn't work :( Quote Development & Research Department @ Elven Soft
*Experts* mutant Posted September 4, 2003 *Experts* Posted September 4, 2003 You would have to use that API. What do you mean it doesnt work? Are there any errors or what is happening? Quote
Administrators PlausiblyDamp Posted September 4, 2003 Administrators Posted September 4, 2003 Any chance you could show us the code you are using? Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
PROKA Posted September 4, 2003 Author Posted September 4, 2003 Well, nothing happens :) here u go : Private Declare Function ExitWindowsEx Lib "user32" (ByVal uFlags As Long, ByVal dwReserved As Long) As Long Const EWX_LOGOFF = 0 Const EWX_SHUTDOWN = 1 Const EWX_REBOOT = 2 Const EWX_FORCE = 4 Private Sub Form_Load() ExitWindowsEx(EWX_FORCE Or EWX_REBOOT, 0) End Sub Quote Development & Research Department @ Elven Soft
*Experts* mutant Posted September 5, 2003 *Experts* Posted September 5, 2003 Change all Long declarations to Integers. Also, when using Win2000, XP or 2003 you cant just shut off the computer, your application needs permission. Quote
PROKA Posted September 5, 2003 Author Posted September 5, 2003 ok thanks, I found a native.net way to do it . Quote Development & Research Department @ Elven Soft
Administrators PlausiblyDamp Posted September 5, 2003 Administrators Posted September 5, 2003 ...and the native .Net way to do it is? Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
PROKA Posted September 6, 2003 Author Posted September 6, 2003 I was wrong, sorry, is not native ... it's 'transcribed' for vb.net :> sorry again Quote Development & Research Department @ Elven Soft
doctorcpu Posted July 13, 2004 Posted July 13, 2004 Change all Long declarations to Integers. Also' date=' when using Win2000, XP or 2003 you cant just shut off the computer, your application needs permission.[/quote'] Can you provide more info on how to provide permissions for 2k and xp? Quote
bri189a Posted July 13, 2004 Posted July 13, 2004 The context in which the procedure is running under. Plaus should be able to give you a more in depth description that this as I haven't done it myself for API's. Basically when a program runs it runs in the context of the user who started it. There are these things called sePriviledges that a token (a user) has that allows them to do certain system events such as shutting down. the se priveldge is not enabled under 2000 for security reasons, you have to adjust token priveledges to allow it. There are several API's that you will have to call and use to do this. I remember doing this a year or so ago and finally gave up because it got to complicated at the time. It's possible, I've seen it, so if you want it that bad it's out there. Search MSDN for seAllowShutdown, sePriviledges (I think), AdjustTokenPriviledges (I think - just put Adjust Token if that doesn't come up with anything), and it will lead you to all sorts of information. I remember MSDN actually has an example on using the shutdown api in .NET and posts a warning as to why it won't work on 2000. I know this isn't much to go on, but until Plaus or somebody else more experienced with permissions gets back to you, it will give you something to look at.... Quote
Recommended Posts