我查了一些资料和一些源程序看到ExitWindowsEx(EWX_SHUTDOWN and EWX_POWEROFF,1);这段代码用来关机,可是不能关机,资料书上也是这么写的。请教各位了!

解决方案 »

  1.   

    系统不一样关机的api函数不同
      

  2.   


    原来在win98下 ExitWindowsEx(1,0); 
    在winNT模式下
     
      var 
    VerInfo:TOSVersionInfo; 
    hToken:THANDLE; 
    tkp:TOKEN_PRIVILEGES; 
    Nothing:Cardinal; 
    begin 
    VerInfo.dwOSVersionInfoSize:=SizeOf(VerInfo); 
    GetVersionEx(VerInfo); 
    if VerInfo.dwPlatformId=VER_PLATFORM_WIN32_NT then 
    Begin 
      OpenProcessToken(GetCurrentProcess,TOKEN_ADJUST_PRIVILEGES or TOKEN_QUERY,hToken); 
      LookupPrivilegeValue(nil,'SeShutdownPrivilege',tkp.Privileges[0].Luid); 
      tkp.PrivilegeCount:= 1; 
      tkp.Privileges[0].Attributes:= SE_PRIVILEGE_ENABLED; 
      AdjustTokenPrivileges(hToken, FALSE, tkp, 0,nil, Nothing); 
      End; 
      ExitWindowsEx(//Your option here,see msdn or win32help); 
    end; 以后要先去搜索贴子,再来提问。 
      

  3.   

    Google上N个例子http://lysoft.7u7.net