我修改了下列代码,系统用administrator权限登陆没有问题,但是用user权限登陆出现<br>1300错误。<br>代码如下:<br>procedure TForm1.modifysystime(Newtime: Tsystemtime);<br>const<br> SE_SHUTDOWN_NAME = 'SeSystemTimePrivilege'; // Borland forgot this declaration<br>var<br> hToken : THandle;<br> tkp : TTokenPrivileges;<br> tkpo : TTokenPrivileges;<br> zero : DWORD;<br> errId:integer;<br>begin<br> zero:=0;<br> {if not OpenProcessToken(GetCurrentProcess(),TOKEN_ADJUST_PRIVILEGES or TOKEN_QUERY, hToken) then begin<br> MessageBox( 0, 'Exit Error', 'OpenProcessToken() Failed', MB_OK );<br> Exit;<br> end;} // if not OpenProcessToken( GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES or TOKEN_QUERY, hToken)<br> if not OpenProcessToken( GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES or TOKEN_QUERY, hToken) then<br> begin<br> MessageBox( 0, 'Exit Error', 'OpenProcessToken() Failed', MB_OK );<br> Exit;<br> end; // if not OpenProcessToken( GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES or TOKEN_QUERY, hToken)<br><br>// SE_SHUTDOWN_NAME<br> if not LookupPrivilegeValue( nil, 'SeSystemTimePrivilege' , tkp.Privileges[ 0 ].Luid ) then<br> begin<br> MessageBox( 0, 'Exit Error', 'LookupPrivilegeValue() Failed', MB_OK );<br> Exit;<br> end; // if not LookupPrivilegeValue( nil, 'SeShutdownPrivilege' , tkp.Privileges[0].Luid )<br> tkp.PrivilegeCount := 1;<br> tkp.Privileges[ 0 ].Attributes := SE_PRIVILEGE_ENABLED;<br> AdjustTokenPrivileges(hToken, False,tkp , SizeOf(tkp), tkpo, zero );<br> if Boolean( GetLastError() ) then begin<br> errId:=GetLastError();<br> showMessage('AdjustTokenPrivileges ErrorId:'+inttostr(errId));<br> Exit;<br> end // if Boolean( GetLastError() )<br> //else ExitWindowsEx( EWX_FORCE or EWX_SHUTDOWN, EWX_POWEROFF);<br> else<br> begin<br> if not setlocaltime(Newtime) then<br> begin<br> errId:=GetLastError();<br> showMessage('setlocaltime ErrorId:'+inttostr(errId));<br> end;<br> end;<br> AdjustTokenPrivileges( hToken, true,tkpo, SizeOf(TTokenPrivileges), tkp, zero );<br>end;