Registriert seit: 29. Mai 2002
37.621 Beiträge
Delphi 2006 Professional
|
Re: CreateProcessAsUser
18. Nov 2004, 11:58
So geht es:
Delphi-Quellcode:
uses MpuWinNT;
function CreateProcessAsLogon( const User, PW, Application: WideString):
Boolean;
var
si : TStartupInfoW;
pif : TProcessInformation;
begin
si.cb := SizeOf(TStartupInfoW);
si.dwFlags := STARTF_USESHOWWINDOW;
si.wShowWindow := 1;
si.lpReserved := nil;
si.lpDesktop := nil;
si.lpTitle := nil;
Result := CreateProcessWithLogonW(PWideChar(User), nil, PWideChar(PW),
LOGON_WITH_PROFILE, nil, PWideChar(Application),
CREATE_DEFAULT_ERROR_MODE, nil, nil, si, pif);
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
if not CreateProcessAsLogon(' Administrator', ' gina', ' Notepad.exe') then
RaiseLastOSError;
end;
Michael Ein Teil meines Codes würde euch verunsichern.
|
|
Zitat
|