Вниз
Скачать: CL | DM;

Проблема с запуском программы от лица другого пользователя   Найти похожие ветки 

 
Виталик ©   (2005-04-26 19:11) [0]

function TService1.StartAsUser(const CmdLine: string):boolean;
var
 h: Cardinal;
 s: TStartupInfo;
 p: TProcessInformation;
 dir: string;
begin
 dir:=ExtractFileDir(CmdLine);
 result:=LogonUser(Pchar("UserName"),nil,Pchar("userpassword"), LOGON32_LOGON_INTERACTIVE, LOGON32_PROVIDER_DEFAULT, h);
 s.cb := SizeOf(s);
 s.lpReserved:=nil;
 s.lpDesktop:=PChar("");
 s.lpTitle:=nil;
 s.dwFlags:=STARTF_USESHOWWINDOW;
 s.wShowWindow:=SW_Show;
 s.cbReserved2:=0;
 s.lpReserved2:=nil;

 result:=CreateProcessAsUser(h, @CmdLine[1], nil,nil, nil, false, CREATE_DEFAULT_ERROR_MODE, nil, @dir[1], s, p);

 CloseHandle(p.hThread);
 CloseHandle(p.hProcess);
 CloseHandle(h);
end;

После выполнения ровно ничего не происходит.

при LogonUser Result=-1
при CreateProcessAsUser Result=1314

Что делать?
Функция вызывается из сервиса.


 
kami ©   (2005-04-26 20:04) [1]

поиск - оно рулез  http://delphimaster.net/view/4-1109896516/


 
kami ©   (2005-04-26 20:10) [2]

А вообще - как пишет MSDN
The function returns an impersonation token, not a primary token. You cannot use this token directly in the CreateProcessAsUser function. However, you can call the DuplicateTokenEx function to convert the token to a primary token, and then use it in CreateProcessAsUser.



Страницы: 1 вся ветка

Скачать: CL | DM;



Память: 0.45 MB
Время: 0.022 c
1-1117024248
Karlson
2005-05-25 16:30
2005.06.14
Картинки для BitBtn


1-1117444953
54321
2005-05-30 13:22
2005.06.14
Поверх всех окон


1-1117568412
Demonix
2005-05-31 23:40
2005.06.14
Компоненты ListBox и ComboBox


14-1116784402
Vulko
2005-05-22 21:53
2005.06.14
Как сделать div на c++ ?


14-1116963284
Agent[007]
2005-05-24 23:34
2005.06.14
WinXP и OpenGL




   Наверх