![]() |
| ||
|
|
Новости |
Поиск |
FAQ |
Статьи |
Книги |
Новости VCL
| | Форумы ЧАТ |
Орешник |
|
| |||
| |||
« предыдущая ветвь | форум | следующая ветвь »
Запуск приложения
mishabik © (2004-11-16 17:19:00)Подскажите, как запустить приложение от имени зарегистрированного пользователя системы. Имя пользователя и пароль известны
mishabik (2004-11-17 13:18:00) [1]Спасибо, попробую.
BiN (2004-11-17 09:39:00) [2]>> Burmistroff (16.11.04 20:08) [1]
В W2k в пользовательском контексте работать не будет.
Burmistroff (2004-11-16 20:08:00) [3]procedure WinExecAsUser(FileName: string; username: string; password:
string; Visibility:
integer);
var { V1 by Pat Ritchey, V2 by P.Below }
zAppName : array[0..512] of char;
StartupInfo : TStartupInfo;
ProcessInfo : TProcessInformation;
h : thandle;
begin { WinExecAndWait32V2 }
StrPCopy(zAppName, FileName);
FillChar(StartupInfo, Sizeof(StartupInfo), #0);
StartupInfo.cb := Sizeof(StartupInfo);
StartupInfo.dwFlags := STARTF_USESHOWWINDOW;
StartupInfo.wShowWindow := Visibility;
if not LogonUser(pchar(username), '.', pchar(Password),
LOGON32_LOGON_INTERACTIVE,
LOGON32_PROVIDER_DEFAULT, h) then
MessageBoxA(0, PChar(SysErrorMessage(GetLastError)), 'Error', MB_OK);
CreateProcessAsUser(h, nil,
zAppName, { pointer to command line string }
nil, { pointer to process security attributes }
nil, { pointer to thread security attributes }
false, { handle inheritance flag }
CREATE_DEFAULT_ERROR_MODE,
nil, { pointer to new environment block }
nil, { pointer to current directory name }
StartupInfo, { pointer to STARTUPINFO }
ProcessInfo); { pointer to PROCESS_INF }
if GetLastError <> 0 then MessageBoxA(0, PChar(SysErrorMessage(GetLastError)), 'Error', MB_OK);
end;