using system;
using system.runtime.interopservices;
// public static void reboot() 重啟
// public static void poweroff()關機
// public static void logoff()登出
// public static void closemonitor(intptr handle)關閉顯示器
// public static void openmonitor(intptr handle)開啟顯示器
public class mycontrol
[dllimport("kernel32.dll", exactspelling = true)]
private static extern intptr getcurrentprocess();
[dllimport("advapi32.dll", exactspelling = true, setlasterror = true)]
private static extern bool openprocesstoken(intptr h, int acc, ref intptr phtok);
[dllimport("advapi32.dll", setlasterror = true)]
private static extern bool lookupprivilegevalue(string host, string name, ref long pluid);
[dllimport("advapi32.dll", exactspelling = true, setlasterror = true)]
private static extern bool adjusttokenprivileges(intptr htok, bool disall, ref tokpriv1luid newst, int len, intptr prev, intptr relen);
[dllimport("user32.dll", exactspelling = true, setlasterror = true)]
private static extern bool exitwindow***(int doflag, int rea);
[dllimport("user32.dll")]
public static extern intptr sendmessage(intptr hwnd, uint msg, uint wparam, int lparam);
private const int se_privilege_enabled = 0x00000002;
private const int token_query = 0x00000008;
private const int token_adjust_privileges = 0x00000020;
private const string se_shutdown_name = "seshutdownprivilege";
private const int ewx_logoff = 0x00000000;
private const int ewx_shutdown = 0x00000001;
private const int ewx_reboot = 0x00000002;
private const int ewx_force = 0x00000004;
private const int ewx_poweroff = 0x00000008;
private const int ewx_forceifhung = 0x00000010;
private const uint wm_syscommand = 0x0112;
private const uint sc_monitorpower = 0xf170;
private static void doexitwin(int doflag)
public static void reboot()
public static void poweroff()
public static void logoff()
public static void closemonitor(intptr handle)
public static void openmonitor(intptr handle)
}
Ubuntu下外接顯示器雙屏顯示的方法
日期 2008 05 10 字型 大 中 小 由於我用的是筆記本.螢幕有點少.所以有的時候想外接顯示器來顯示更大的區域,如果是在windows下那可是很方便的事情.只需要按一下fn f4就可以了.但現在在ubuntu linux下.就變成了一件有點麻煩的事情了,以前沒找到好的方法,現在參考了一些文件...
C 實現阻止關閉顯示器和系統待機
dllimport kernel32.dll staticexternuintsetthreadexecutionstate executionflagflags flags enumexecutionflag uint 它就乙個flags引數,這個引數有三個選項,可以組合使用。主要說明如下 因此,...
C 中改變顯示器的解析度
using system using system.drawing using system.collections using system.ponentmodel using system.windows.forms using system.data using system.runtime....