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# ,
上一个:c# 条形码(求指教)
下一个:代码控制编译C#程序