> {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';
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