Article

From:
To:
Christian Wimmer
Subject:
Re: Impersonate user from service: SetTokenInformation err 998 "Invalidaccess
Newsgroup:
embarcadero.public.delphi.nativeapi

Re: Impersonate user from service: SetTokenInformation err 998 "Invalidaccess

> {quote:title=Christian Wimmer wrote:}{quote}
> That should be
> @dwSessionId instead of Pointer(dwSessionId)
> in SetTokenInformation
> 
> Christian Wimmer

That removed the error thanks.

It still does not work though, whether I call    DuplicateTokenEx(hPToken,                             MAXIMUM_ALLOWED,                             Nil,                             SecurityIdentification,                             TokenPrimary,                             FhUserTokenDup) or    DuplicateTokenEx(hPToken,                             MAXIMUM_ALLOWED,                             Nil,                             SecurityImpersonation,                             TokenImpersonation,                             FhUserTokenDup)
Right after calling xbwImpersonateLoggedOnUser, I call     WriteIntRegKey(HKEY_CURRENT_USER,cExplorerPolicies,'NoControlPanel',0) with   const
cExplorerPolicies = '\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer';
and
procedure WriteIntRegKey(RootKey: DWord; NameOfKey,StringName: String; IntValue: DWord);
  var Reg: TRegistry;
  begin
    Reg := TRegistry.Create;  
    try
      Reg.RootKey := RootKey;
      if not Reg.OpenKey(NameofKey,TRUE) then
        Write2Log('WriteIntRegKey OpenKey failed');
      Reg.WriteInteger(StringName,IntValue);
    except
      on E:Exception do
Write2Log('WriteIntRegKey: ' + NameOfKey + '\' + StringName + ': ' + E.Message);
    end;
    Reg.Free;
  end; { WriteIntRegKey }

but I don't see the registry key appearing. (this works in a 'normal' exe)
jan
FYI: Attachments and HTML formatted text are not indexed
 
 
Originally created by
Tamarack Associates
Sun, 19 May 2024 22:16:05 UTC
Copyright © 2009-2024
HREF Tools Corp.