[C#] 讓程式不顯示在工作管理員中

使用此方式讓程式不顯示在工作管理員中

可以避免程式遭使用者誤關閉

[DllImport("user32.dll")]
public static extern int SetWindowLong(IntPtr window, int index, int value);

[DllImport("user32.dll")]
public static extern int GetWindowLong(IntPtr window, int index);

public static void setTaskmanager_Disable(IntPtr Handle)
{
     /* GWL EXSTYLE  = -20 得到或設置擴展窗口的STYLE */
     const int GWL_EXSTYLE = -20;
     const int WS_EX_TOOLWINDOW = 0x00000080;
     const int WS_EX_APPWINDOW = 0x00040000;
     int windowStyle = Win32APi.GetWindowLong(Handle, GWL_EXSTYLE);
     SetWindowLong(Handle, GWL_EXSTYLE, windowStyle | WS_EX_TOOLWINDOW);
}


使用方式:
setTaskmanager_Disable(Handle);

留言

這個網誌中的熱門文章

[TCL] 基本語法與指令 - 2. TCL 語法

[TCL] 基本語法與指令 - 1. TCL 簡介

[TCL] 基本語法與指令 - 3. 資料型態