I never programmed a winapi so i have a little problem here .
I need turn off my pc from my application .
I found this example link text then i found this example how to change privileges link text
But i have problem how to get that parameter HANDLE hToken // access token handle
I think i need to make it in the next order to get the parameter OpenProcessToken LookupPrivilegeValue AdjustTokenPrivileges but there are a lot parameters that i have no idea what to do with them .
maybe you have jere some example how i get that HANDLE hToken parameter to make that work .
By the way I already saw the following post link text
Thanks a lot all you .
This is a bit much for the comments on Daniel's answer, so I'll put it here.
It looks like your main issue at this point is that your process isn't running with the priveleges required to perform a system shutdown.
The docs for ExitWindowsEx contain this line:
They also have some example code. In a pinch, you can just copy that.
http://msdn.microsoft.com/en-us/library/aa376868(VS.85).aspx
Try
You could use ShellExecute() to call shutdown.exe
Some working code for
InitiateSystemShutdownEx
:So far as I can tell, the advantage to this over the
ExitWindowsEx
solution is that the calling process does not need to belong to the active user.