请问在win2000中如何关机(100分)

  • 主题发起人 主题发起人 duron187
  • 开始时间 开始时间
D

duron187

Unregistered / Unconfirmed
GUEST, unregistred user!
请问在win2000中如何关机,我用

了ExitWindowsEx(EWX_SHUTDOWN,dwreserved)可是不行。
 
在NT/2000/xp 关机要有系统权限,据说ahm2000的关机控件代码中有,可以去看看
 
试试:ExitWindowsEx(EWX_SHUTDOWN and EWX_POWEROFF ,1);
 
開始/關機/選擇"關機",確定.[:D]

ExitWindowsEx(EWX_POWEROFF,0);
 
const //[EXIT CODE]
EI_SYSEXIT_LOGOFF =$00;
EI_SYSEXIT_SHUTDOWN =$01;
EI_SYSEXIT_REBOOT =$02;
EI_SYSEXIT_FORCE =$04;
EI_SYSEXIT_POWEROFF =$08;
EI_SYSEXIT_FORCEIFHUNG =$10;
FUNCTION FkSystemExit(vType:INTEGER;vForce:BOOL):BOOL;
VAR
hToken: THANDLE;
hProc: THANDLE;
iLUID: INT64;
mPriv, mNewPriv: TOKEN_PRIVILEGES;
dLength: DWORD;
dExit:DWORD;
BEGIN
IF vForce THEN dExit:=vType+EWX_FORCE ELSE dExit:=vType;
//[WIN9X]
IF Win32Platform=VER_PLATFORM_WIN32_WINDOWS THEN
BEGIN Result:=ExitWindowsEx(dExit,0); END;
//[WINNT]
IF Win32Platform=VER_PLATFORM_WIN32_NT THEN
BEGIN
hProc:=GetCurrentProcess() ;
OpenProcessToken(hProc,TOKEN_ADJUST_PRIVILEGES +TOKEN_QUERY,hToken);
LookupPrivilegeValue('','SeShutdownPrivilege',iLUID);
mPriv.PrivilegeCount:=1;
mPriv.Privileges[0].Attributes:=SE_PRIVILEGE_ENABLED;
mPriv.Privileges[0].Luid :=iLUID;
AdjustTokenPrivileges(hToken,False,mPriv,
(4+(12*mPriv.PrivilegeCount)),
mNewPriv,dLength);
Result:=ExitWindowsEx(dExit,0);
END;
//[END;]
END;
[:D][:D][:D][:D][:D][:D]
用FkSystemExit(EI_SYSEXIT_POWEROFF,TRUE);不要告诉我不行!!!!!!![:)][:)][:)]
 
bool MyExitWindowsEx(UINT uFlag)
{
bool result = false;
OSVERSIONINFO osv; //定义一个操作系统信息的结构体
osv.dwOSVersionInfoSize=sizeof(OSVERSIONINFO);
GetVersionEx(&osv); //查询当前操作系统
if(osv.dwPlatformId==VER_PLATFORM_WIN32_NT) //判断是否是2000/NT
{

//下面为向操作系统获取权限操作
HANDLE hProcess,hToken;
TOKEN_PRIVILEGES Privileges;
LUID luid;
hProcess=GetCurrentProcess();

//下面为打开当前进程对话
OpenProcessToken(hProcess,TOKEN_ADJUST_PRIVILEGES,&hToken);
Privileges.PrivilegeCount=1;
LookupPrivilegeValue(NULL,SE_SHUTDOWN_NAME,&luid);
Privileges.Privileges[0].Luid=luid;
Privileges.Privileges[0].Attributes=SE_PRIVILEGE_ENABLED;
AdjustTokenPrivileges(hToken,FALSE,&Privileges,NULL,NULL,NULL);
}
ExitWindowsEx(uFlag,0);
result = true;
return result;
}
 
你試試cayu的方法,應該可以的,其實以前有很多這方面的討論,你還可以去搜索一下,
cayu是對的!!!!
 
后退
顶部