Код
function CreateProcessWithLogonW(user:pwidechar; domain:pwidechar;
passw:pwidechar; flags: DWORD; lpApplicationName: PwideChar; lpCommandLine: PwideChar;
dwCreationFlags: DWORD; lpEnvironment: Pointer;
lpCurrentDirectory: PWideChar; const lpStartupInfo: TStartupInfo;
var lpProcessInformation: TProcessInformation): BOOL; stdcall;external 'advapi32.dll' name 'CreateProcessWithLogonW';
var
si: TSTARTUPINFO;
pif: PROCESS_INFORMATION;
begin
si.cb := SizeOf(tstartupinfo);
si.dwFlags := STARTF_USESHOWWINDOW;
si.wShowWindow := SW_SHOWDEFAULT;
si.lpReserved := nil;
si.lpDesktop := nil;
si.lpTitle := nil;
CreateProcessWithLogonW('Admin', nil, '12345', 0,
'cmd.exe',nil,0, nil, nil, si, pif);