using system;
using system.collections.generic;
using system.text;
using system.runtime.interopservices;
[dllimport("kernel32.dll", exactspelling = true)]
internal static extern intptr getcurrentprocess();
[dllimport("advapi32.dll", exactspelling = true, setlasterror = true)]
internal static extern bool openprocesstoken(intptr h, int acc, ref intptr phtok);
[dllimport("advapi32.dll", setlasterror = true)]
internal static extern bool lookupprivilegevalue(string host, string name, ref long pluid);
[dllimport("advapi32.dll", exactspelling = true, setlasterror = true)]
internal static extern bool adjusttokenprivileges(intptr htok, bool disall, ref tokpriv1luid newst, int len, intptr prev, intptr relen);
[dllimport("user32.dll", exactspelling = true, setlasterror = true)]
internal static extern bool exitwindow***(int ***, int rea);
internal const int se_privilege_enabled = 0x00000002;
internal const int token_query = 0x00000008;
internal const int token_adjust_privileges = 0x00000020;
internal const string se_shutdown_name = "seshutdownprivilege";
internal const int ewx_logoff = 0x00000000;
internal const int ewx_shutdown = 0x00000001;
internal const int ewx_reboot = 0x00000002;
internal const int ewx_force = 0x00000004;
internal const int ewx_poweroff = 0x00000008;
internal const int ewx_forceifhung = 0x00000010;
private static void doexitwin(int ***)
/// /// 重啟
///
public static void reboot()
/// /// 關機
///
public static void poweroff()
/// /// 登出
///
public static void logooff()
}}
使用c 對windows進行關機 重啟或登出
方法一 呼叫windows自帶的shutdown.exe 缺點 會出現倒計時視窗 system.diagnostics.process.start shutdown.exe r f t 15 shutdown引數含義 r關閉並重啟動此計算機 f 強制執行的應用程式關閉而沒有警告 t 15 延時15秒...
windows 上驅動阻止關機重啟操作
windows 上關機重啟有很多相關的操作 hook 乙個點搞不定 具體需要以下 4 處來布控 ssdt hook ntinitiatepoweraction 函式 直接返回失敗廢掉這個函式 ssdt hook ntsetsystempowerstate 函式 也是直接返回失敗 shadow ssd...
windows 遠端控制關機和重啟命令
關機 shutdown s t 0 重啟 shutdown r t 0 開啟執行框 win r鍵 輸入上述命令即可,後面的數字表示關機 重啟延遲的時間 at 12 00 shutdown s 在執行裡輸入這個然後敲回車 他就會在12點種的時候關機 用法 shutdown i l s r a f m ...