This example performs an OS/2 System Shutdown from a program.
#define INCL_WINWORKPLACE
#define INCL_DOSFILEMGR
#define INCL_DOSERRORS
#include <os2.h>
#include <stdio.h>
int main(VOID)
{
HAB hab = NULLHANDLE; /* Window handle */
HMQ hmq = NULLHANDLE; /* Message queue handle */
BOOL fSuccess = 0; /* Win API success indicator */
hab = WinInitialize( 0 );
hmq = WinCreateMsgQueue( hab, 0 );
/* Prevent our program from hanging the shutdown. If this call is
omitted, the system will wait for us to do a WinDestroyMsgQueue. */
fSuccess = WinCancelShutdown( hmq, TRUE );
/* Shutdown the system! */
printf("System Shutdown will now be attempted...\n");
fSuccess = WinShutdownSystem( hab, hmq );
if (!fSuccess) {
return 1;
} else {
return NO_ERROR;
} /* endif */
}