Mit:
Delphi-Quellcode:
function TProcess.InitOwnerName: WideString;
var
hProcess : THandle;
ppsidOwner : PSID;
SecDescriptor : PSECURITY_DESCRIPTOR;
err : DWord;
s : string;
SIDType : DWORD;
Owner : WideString;
const
SE_UNKNOWN_OBJECT_TYPE: DWord = 0;
SE_FILE_OBJECT : DWord = 1;
SE_SERVICE : DWord = 2;
SE_PRINTER : DWord = 3;
SE_REGISTRY_KEY : DWord = 4;
SE_LMSHARE : DWord = 5;
SE_KERNEL_OBJECT : DWord = 6;
SE_WINDOW_OBJECT : DWord = 7;
begin
Owner := '';
hProcess := OpenProcess(PROCESS_QUERY_INFORMATION or GENERIC_READ, False, FProcID);
if (hProcess <> 0) then
begin
err := GetSecurityInfo(hProcess, SE_KERNEL_OBJECT, OWNER_SECURITY_INFORMATION, @ppsidOwner, nil, nil, nil,
@SecDescriptor);
if (err = 0) then
begin
s := SidToString(ppsidOwner);
FOwnerStrSID := s;
FPOwnerSID := ppsidOwner;
StrSIDToName(s, Owner, SIDType);
LocalFree(Cardinal(SecDescriptor));
end;
CloseHandle(hProcess);
end;
Result := Owner;
end;
Bekommt man den Besitzer eines Prozesses.
Um an den übergeordneten Prozess zu kommen wirst du ihn wohl aus einer Prozessliste raussuchen müssen.