RE: Windows Shutdown

new topic     » topic index » view thread      » older message » newer message

> Hello to all,
> 
> I have been using the following code at the end of this message to try 
> and shutdown windows, but unfortunately it only logs the user off, and 
> not completely shutdown the PC. I did some research on the MSN website, 
> and I found out to shut down or restart the system, the calling process 
> must use the AdjustTokenPrivileges function to enable the 
> SE_SHUTDOWN_NAME privilege. The problem is I do not have a clue on how 
> to do that. Can anyone help out with this?
> 
> constant USER32 = open_dll("user32")
> 
> constant SHUTDOWNEX = define_c_func(USER32, "ExitWindowsEx", {C_UINT, 
> C_LONG}, C_INT)
> global constant
> 
>   EWX_FORCE = 4,
>   EWX_LOGOFF = 0,
>   EWX_POWEROFF = 8,
>   EWX_REBOOT = 2,
>   EWX_SHUTDOWN = 1
> 
> 
> global procedure win32_shutdown(integer shutdown_type)
>     integer x
>     x = c_func(SHUTDOWNEX, {shutdown_type, 0})
> end procedure
> 
> Thanks in advance,
> Chris


Hmm, I've seen this API used to shut down windows before with no
issues.  Looking back at the example program that I have, the call would 
be:
win32_shutdown( or_all({EWX_SHUTDOWN,EWX_FORCE}) )

Don

new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu