• Windows快速关机与重启


    #include <windows.h>
    
    int WINAPI WinMain( __in HINSTANCE hInstance, __in_opt HINSTANCE hPrevInstance, __in_opt LPSTR lpCmdLine, __in int nShowCmd )
    {
        int SE_SHUTDOWN_PRIVILEGE = 0x13;
        typedef int (WINAPI *PFNRtlAdjustPrivilege)( INT, BOOL, BOOL, BOOL* );
        typedef int (WINAPI *PFNZwShutdownSystem)( INT );
    
        HMODULE hModule = LoadLibrary( TEXT("ntdll.dll") );
        if( hModule != NULL)
        {
            PFNRtlAdjustPrivilege pfnRtlAdjustPrivilege = (PFNRtlAdjustPrivilege)GetProcAddress( hModule, "RtlAdjustPrivilege" );
            PFNZwShutdownSystem pfnZwShutdownSystem = (PFNZwShutdownSystem)GetProcAddress( hModule, "ZwShutdownSystem" );
            if( pfnRtlAdjustPrivilege != NULL &&
                pfnZwShutdownSystem != NULL )
            {
                BOOL bEnabled = 0;
                int nResult = pfnRtlAdjustPrivilege( SE_SHUTDOWN_PRIVILEGE,
                                                  TRUE, TRUE, &bEnabled );
                if( nResult == 0xC000007C )
                nResult = pfnRtlAdjustPrivilege( SE_SHUTDOWN_PRIVILEGE,
                                              TRUE, FALSE, &bEnabled );
                nResult = pfnZwShutdownSystem( 0 );
                //快速关闭系统 = 0;
                //快速重启 = 1;
                //快速关机 = 2;
            }
        }
    }
    
  • 相关阅读:
    JS原生带小白点轮播图
    JS原生轮播图
    Vue.js小案例(2)
    Vue.js小案例(1)
    Vuejs入门级简单实例
    Vue.js简单入门
    微信登录oauth2.0
    PHP四维数组、三维数组封装遍历
    常用linux命令30个
    好架构是进化来的,不是设计来的
  • 原文地址:https://www.cnblogs.com/LinuxHunter/p/1885832.html
Copyright © 2020-2023  润新知