当前位置:编程学习 > C#/ASP.NET >>

C#实现关机、重启、注销

01        <PRE class=brush:csharp;collapse:true;>        //实现关机,重启,注销
02         [StructLayout(LayoutKind.Sequential, Pack = 1)]
03         internal struct TokPriv1Luid
04         {
05             public int Count;
06             public long Luid;
07             public int Attr;
08         }
09   
10         //[DllImport]允许.NET调用任意非托管的C/C++基类库,包括操作系统中的API.但与基于COM的软件通信时,[DLLImport]不能使用.
11         [DllImport("kernel32.dll", ExactSpelling = true)]
12         internal static extern IntPtr GetCurrentProcess();
13   
14         [DllImport("advapi32.dll", ExactSpelling = true, SetLastError = true)]
15         internal static extern bool OpenProcessToken(IntPtr h, int acc, ref   IntPtr phtok);
16   
17         [DllImport("advapi32.dll", SetLastError = true)]
18         internal static extern bool LookupPrivilegeValue(string host, string name, ref   long pluid);
补充:软件开发 , C# ,
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,