Ver Mensaje Individual
  #9  
Antiguo 25-04-2007
Avatar de seoane
[seoane] seoane is offline
Miembro Premium
 
Registrado: feb 2004
Ubicación: A Coruña, España
Posts: 3.717
Reputación: 24
seoane Va por buen camino
Yaeris, eso ocurre porque no tienes suficientes privilegios. Pero lo bueno de ser administrador es que tu mismo te los puedes conceder . La siguiente función permite elevar los privilegios de tu aplicación, de esta forma ya podrás usar la función.

Código Delphi [-]
function EnablePrivilege(PrivilegeName: PChar; Enable: Boolean): Boolean;
var
  hToken: THandle;
  Tp: TOKEN_PRIVILEGES;
  Luid: TLargeInteger;
begin
  Result:= FALSE;
  if OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES or
    TOKEN_QUERY or TOKEN_READ, hToken) then
    if LookupPrivilegeValue(nil,PrivilegeName,Luid) then
    begin
      Tp.PrivilegeCount:= 1;
      Tp.Privileges[0].Luid:= Luid;
      if Enable then
        Tp.Privileges[0].Attributes:= SE_PRIVILEGE_ENABLED
      else
        Tp.Privileges[0].Attributes:= 0;
      Result:= AdjustTokenPrivileges(hToken,FALSE,Tp,0,nil,PDWORD(nil)^);
      CloseHandle(hToken);
    end;
end;

Por ejemplo:
Código Delphi [-]
EnablePrivilege('SeDebugPrivilege', TRUE);
// Aqui usamos la funcion
GetModulesProcess(524,2);
EnablePrivilege('SeDebugPrivilege', FALSE);
Responder Con Cita