Главная страница
Top.Mail.Ru    Яндекс.Метрика
Текущий архив: 2005.06.14;
Скачать: 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 вся ветка

Текущий архив: 2005.06.14;
Скачать: CL | DM;

Наверх




Память: 0.47 MB
Время: 0.035 c
14-1116743587
vidiv
2005-05-22 10:33
2005.06.14
time.nist.gov


6-1111941558
ALex_2000
2005-03-27 20:39
2005.06.14
DataSnap (Socketconection)


14-1117002765
Гаврила
2005-05-25 10:32
2005.06.14
Automatic Delphi 7 Code Completion


1-1117102427
Antonn
2005-05-26 14:13
2005.06.14
Несколько вопросов по правильности кода


3-1115524614
MickL
2005-05-08 07:56
2005.06.14
BLOB поле