小编Roh*_*hit的帖子

在计算机锁定时,为关闭计算机而创建的Windows服务无效

我在C#中创建了一个Windows服务来关闭计算机.

计算机未锁定时(Ctrl + Alt + Del),该服务正常.

但有些人在我的电脑被锁定时它没有关闭.

// call
DoExitWin(EWX_SHUTDOWN);

[StructLayout(LayoutKind.Sequential, Pack = 1)]
internal struct TokPriv1Luid
{
    public int Count;
    public long Luid;
    public int Attr;
}

[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 …
Run Code Online (Sandbox Code Playgroud)

.net c# windows-services

5
推荐指数
1
解决办法
2282
查看次数

标签 统计

.net ×1

c# ×1

windows-services ×1