Jump to content
Xtreme .Net Talk

Recommended Posts

Posted (edited)

I need to able to shut down Windows 2000 in VB.net. I'm developing an application that will run on an industrial PC interface controlling a piece of machinery in a truck. When a "job" is complete, I need to shut down the interface to avoid corrupting the OS and systems on the PC (as opposed to the operator just cutting the power).

 

I've got this code so far, which allows me to restart and log off, but it won't work for a full shutdown.

 

Declare Function ExitWindowsEx Lib "user32" (ByVal uFlags As Integer, ByVal dwReserved As Integer) As Integer

'Declarations
Public Enum ExitWindowsFlags
   EWX_LOGOFF = 0
   EWX_REBOOT = 2
   EWX_SHUTDOWN = 1
   EWX_FORCE = 4
End Enum
   
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
   ExitWindows(0)
End Sub

 

I think that I need to set some sort of permissions or authorizations to do a full shutdown, but I am having no luck finding a working example to achieve this.

 

Any help would me EXTREMELY appreciated!

 

Wolf

 

:confused::confused:

Edited by Derek Stone

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

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