Windows 95 shutdown function - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Windows 95 shutdown function

I know it is there, but I can't seem to remember the syntax or where to find a referance.


Comments



  • Use ExitWindowsEx using

    EWX_SHUTDOWN || EWX_FORCE as the parameters.



    Timtimtim.






  • : I know it is there, but I can't seem to remember the syntax or where to find a referance.

    :



    Greeting's

    The Windows ShutDown code is one of my favorite toys. For Win95/98 only use



    WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)

    {

    ExitWindowsEx(EWX_SHUTDOWN,0);

    return 0;

    }

    I dont like to force the shutdown right from zero if you want to include it as an option use



    if(!ExitWindowsEx(EWX_SHUTDOWN,0)

    {

    ExitWindowsEx(EWX_SHUTDOWN|EWX_FORCE,0);

    }



    If you want to ShutDown Win95/98/NT/2000

    use

    HANDLE hToken;

    TOKEN_PRIVILEGES tkp;

    WINAPI WinMain(HINSTANCE,HINSTANCE,LPSTR,int)

    {

    if(!OpenProcessToken(GetCurrentProcess(),TOKEN_ADJUST_PRIVILEGES|TOKEN_QUERY,&hToken));

    LookupPrivilegeValue(NULL, SE_SHUTDOWN_NAME,&tkp.Privileges[0].Luid);

    tkp.PrivilegeCount = 1;

    tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;

    AdjustTokenPrivileges(hToken, FALSE, &tkp, 0,(PTOKEN_PRIVILEGES)NULL, 0);

    if(!ExitWindowsEx(EWX_REBOOT, 0))

    {

    ExitWindowsEx(EWX_REBOOT|EWX_FORCE,0);

    }

    return 0;

    }



    also windows.h is the only include file you'll need for any of this








Sign In or Register to comment.