Re: ExitWindowsEx function not working.

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Try perhaps :
http://support.microsoft.com/kb/168796/en-us

It could be that you need also some code to grant this privilege to the
process...

--
Patrice

"cj" <cj@xxxxxxxxxxxxx> a écrit dans le message de news:
%23SW%232cjjGHA.2200@xxxxxxxxxxxxxxxxxxxxxxx
I am an administrator if that matters. Also this does work.

Public Class Form1
Inherits System.Windows.Forms.Form

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
'Shutdown
Dim t As Single
Dim WMIService, Computer As Object
WMIService =
GetObject("Winmgmts:{impersonationLevel=impersonate,(Debug,Shutdown)}")
For Each Computer In
WMIService.InstancesOf("Win32_OperatingSystem")
t = Computer.Win32Shutdown(2 + 4, 0)
Next
End Sub
End Class

cj wrote:
Using VB2003 on Windows XP Pro

Why doesn't this work?

Public Class Form1
Inherits System.Windows.Forms.Form

Private Declare Auto Function ExitWindowsEx Lib "user32.dll" (ByVal
uFlags As Int32, ByVal dwreserved As Int32) As Int32

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button3.Click
Dim retval As Int32
retval = ExitWindowsEx(2 + 4, 0)
End Sub
End Class


.


Quantcast