讓電腦重啟,關機和登出的c 源程式

2021-04-12 23:32:44 字數 1887 閱讀 8573

using system;

using system.collections.generic;

using system.componentmodel;

using system.data;

using system.drawing;

using system.text;

using system.windows.forms;

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 form1()

private void button1_click(object sender, eventargs e)

private void button2_click(object sender, eventargs e)

private void button3_click(object sender, eventargs e)}}

C 或C控制PC電腦關機 重啟 登出

include 功能實現 bool resetwindows dword dwflags,bool bforce 獲得引數的大小,以提供給getversionex來判斷這是乙個新版本的osversioninfo,還是舊版本的 新版本是osversioninfoex。擴充版本 osvi.dwosver...

關機 登出 重啟指令和函式代表的含義

這兒有個api幫助雖然是vb版的,不過所有的引數都是一樣的,可以參考著用的!雖然不全,但大多數都有了,而且還可以自己增加的!好東西就應該大家共享的!補充日期 2002 06 07 11 26 04 定義格式 function returndatatype name datatype1 arg1,da...

vbs實現的定時關機 重啟的指令碼和程式

將下面 存為vbs檔案,如 shutdown.vbs,然後雙擊或在檔案上點右 鍵選擇以命令提示開啟,如果到了你設定重啟的時候,系統會出現關機的對話 框。直接下面 程式會出現關機的對話方塊,最後的回車注釋掉了,正常使用 時,請去掉注釋符。以下 在window 2000 下通過。複製 如下 定時關機或重...