Einzelnen Beitrag anzeigen

CodeX

Registriert seit: 30. Okt 2004
471 Beiträge
 
Delphi 12 Athens
 
#15

Re: Programm von Dienst starten lassen (Jetzt aber wirklich

  Alt 22. Mai 2008, 17:38
Zitat von Remko:
WTSQueryUserToken returns a user's primary token so you don't need to duplicate it. Just past the tokenhandle to CreateProcessAsUser and be sure to pass nil for the desktop param of the startupinfo structure. Something like this...
Yes, you're right this is shorter, but it gives me the environment of SYSTEM and not of the logged in user.

Delphi-Quellcode:
function GetEnvironment(): LPVOID;
var
  SessionID : DWORD;
  hToken : THandle;
begin
  Result := nil;

  WTSQueryUserToken(SessionID, hToken);

  if (not CreateEnvironmentBlock(Result, hToken, True)) then
    Result := nil;
end;
Zitat von Remko:
Notes: WTSQueryUserToken needs Windows XP/2003 or higher, if you need windows 2000 compatibility check Jwscl as it contains a WTSQueryUserTokenEx function that also works on Windows 2000.
OK, good that you remind me, because I do need 2000 compatibility. Unfortunatelly I still can't get Jwscl to work so I can't test WTSQueryUserTokenEx at the moment.


Zitat von Dezipaitor:
Willst du das wirklich alles nur mit der WinAPI machen? Das geht natürlich. Plane aber mal noch 3-4Wochen Zusatzaufwand dafür ein. Ich selbst würde da nur noch die JWSCL benutzen.
Ich würde ja sehr gerne die Jwscl benutzen, aber ich bekomme das leider nicht zum Laufen bei mir. Ich mache jetzt mal eine frische Installation von Jwa und Jwscl dann mal sehen...
  Mit Zitat antworten Zitat