C 關機程式

2021-04-12 12:01:09 字數 1566 閱讀 5028

using system;

using system.runtime.interopservices;

class shoutdown

[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 main() }

C語言實現關機程式

關機程式 include include include sleep的時間可以適當增長點 int main fflush stdout printf n printf 等了這麼久 n sleep 600 printf fflush stdout sleep 600 printf fflush std...

安全關機程式

安全關機程式 發現原因後,很簡單,先把使用者程序全部terminate掉,然後再自動關機。於是就有了本文。具體內容很簡單,用createtoolhelp32snapshot函式得到當前程序快照,然後process32first和process32next函式迴圈得到程序的id號。然後再 呼叫open...

電腦關機程式

思路結合了關機程式和兩頭縮排的 shutdown s t 60是關機命令 sleep 300 函式可以停止300微妙再執行程式 輸入密碼破解程式吧 define crt secure no warnings 1 include include include include include int ...

用C 寫定時關機的程式

12點的時候自動關閉機器。此程式在 win2k 下輕鬆測試通過。說輕鬆是因為即使執行著很多其它程式,依然能夠正常關機。原理非常簡單,也就不用放 上來。就是呼叫一個 api關閉計算機的函式,需要先宣告。dllimport user32.dll exactspelling true,setlasterr...

用C 寫定時關機的程式

原理非常簡單,也就不用放 上來。就是呼叫一個api關閉計算機的函式,需要先宣告。dllimport user32.dll exactspelling true,setlasterror true internal static extern bool exitwindow int int rea 然...