30
workBLOGS . API shutdown and maps
Filed Under (Visual FoxPro, work.BLOG) by WildFire on 30-05-2004
This is the Windows 98SE-compatible snippet I use for shutting down the CPU.
procedure SYSTEMSHUTDOWN
#define EWX_LOGOFF 0
#define EWX_SHUTDOWN 1
#define EWX_REBOOT 2
#define EWX_FORCE 4
#define EWX_POWEROFF 8
#define EWX_FORCEIFHUNG 16
declare integer ExitWindows IN user32;
����������integer dwReserved, integer uReturnCode
declare integer ExitWindowsEx IN user32;
����������integer uFlags, integer dwReserved‘ = ExitWindowsEx(EWX_LOGOFF, 0)
‘ = ExitWindowsEx(EWX_REBOOT, 0)
= ExitWindowsEX(EWX_SHUTDOWN, 0)EndProc
Note: The html CGIs i’m using auto eliminates * so i’m replacing it with ‘.
There’s a better one which can shutdown Windows XP and Windows 2000 and do a lot more ‘cleaning up’ procedures. I’ll post that one later once I figure out to whom I can give credits for that code.
One of the issues yesterday involves this ‘automatic’ shutting down of computers at a given time. There were no problems in the client computers but in the server module, which uses a mapped/shared virtually-created-drive approach, it shows this ‘there are n users connecting to this computer… shutting down will make them whine and howl…’ type of error. For a moment there which lasted for 10 minutes or even more, I was formulating solutions and knocking once again on the doors of WinAPI, hoping that there’s a way I could somehow supress that confirmation.
Only to realize that I can make things easier if I set a different shutdown time for the server and make it do the shutdown process after all the client PCs are knocked out.
Yeah… sometimes the best solution to a problem are those little simple things we often overlook.