Einzelnen Beitrag anzeigen

NicoDE
(Gast)

n/a Beiträge
 
#11

Re: Benutzernamen von Prozessen ermitteln

  Alt 12. Jun 2006, 13:13
Zitat von Olli:
Würdest du dich dazu herablassen zu dieser Funktion und WinStationConnect die C- oder Delphi-Prototypen hier hinzuklimpern?
Dann lasse ich mich mal herab
(wer undokumentierte Funktionen benutzt, sollte Fallbacks implementieren)
Delphi-Quellcode:
// winsta.dll

const
  LOGONID_CURRENT = ULONG(-1);
  SERVERNAME_CURRENT = THandle(nil);

type
  TFNWinStationConnectW = function(
    hServer : THandle;
    SessionId : ULONG;
    TargetSessionId: ULONG;
    pPassword : PWideChar; // use L"" instead of NULL
    bWait : BOOLEAN
  ): BOOLEAN; stdcall;

type
  TFNWinStationDisconnect = function(
    hServer : THandle;
    SessionId: ULONG;
    bWait : BOOLEAN
    ): BOOLEAN; stdcall;

type
  TFNWinStationGetProcessSid = function(
    hServer : THandle;
    ProcessId : ULONG;
    ProcessStartTime: TFileTime;
    pProcessUserSid : PSID;
    var dwSidSize : ULONG
    ): BOOLEAN; stdcall;

// utildll.dll

type
  TFNCachedGetUserFromSid = procedure(
    pSid : PSID;
    pUserName : PWideChar;
    var cbUserName: ULONG
  ); stdcall;
Wie immer ohne Gewähr...

ps: Für WinStationGetProcessSid braucht man kein WinStationConnect, allerdings muss die CreateTime stimmen, ansonsten gibt die WinStationGetProcessSid 'ungültiges Handle' zurück.
  Mit Zitat antworten Zitat