Saludos foristas.
Necesito dejar programado Reiniciar una computadora.
tengo problemas con los permisos ya que no me ejecuta ninguna accion.
La hice con la finalidad de que trabaje con windows xp
Aqui les muestro el codigo que utilizo para los permisos
Código Delphi
[-]
function TForm1.EnablePrivilege(PrivilegeName:PChar;Enable:Boolean):boolean;
var
TokenPriv: TOKEN_PRIVILEGES;
Luid:TLargeInteger;
HToken:THandle;
begin
Result:=FALSE;
if OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES,HToken) then
if LookupPrivilegeValue(NIL,PrivilegeName,Luid) then
begin
TokenPriv.PrivilegeCount:=1;
TokenPriv.Privileges[0].Attributes:= Luid;
if Enable then
TokenPriv.Privileges[0].Attributes:=SE_PRIVILEGE_ENABLED
else
TokenPriv.Privileges[0].Attributes:=0;
Result:=AdjustTokenPrivileges(HToken, FALSE,TokenPriv,0,NIL,PDWORD(nil)^);
CloseHandle(HToken);
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
Application.Terminate;
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
EnablePrivilege('SeShutDownPrivilege',TRUE);
ExitWindowsEx(EWX_REBOOT or EWX_FORCE, 0);
end;
gracias por su tiempo