Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

Development & Research Department @ Elven Soft
  • *Experts*
Posted
Change all Long declarations to Integers. Also, when using Win2000, XP or 2003 you cant just shut off the computer, your application needs permission.
  • 10 months later...
Posted
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?

Posted

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....

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...