指定權(quán)限運行程序
type
_STARTUPINFOW = record
cb: DWORD;
lpReserved: LPWSTR;
lpDesktop: LPWSTR;
lpTitle: LPWSTR;
dwX: DWORD;
dwY: DWORD;
dwXSize: DWORD;
dwYSize: DWORD;
dwXCountChars: DWORD;
dwYCountChars: DWORD;
dwFillAttribute: DWORD;
dwFlags: DWORD;
wShowWindow: Word;
cbReserved2: Word;
lpReserved2: PByte;
hStdInput: THandle;
hStdOutput: THandle;
hStdError: THandle;
end;
STARTUPINFOW = _STARTUPINFOW;
function CreateProcessWithLogonW(lpUserName, lpDomain, lpPassword: LPCWSTR;
dwLogonFlags: DWORD; lpApplicationName: LPCWSTR; lpCommandLine: LPWSTR;
dwCreationFlags: DWORD; lpEnvironment: Pointer; lpCurrentDirectory: LPCWSTR;
const lpStartupInf STARTUPINFOW; var lpProcessInformation: PROCESS_INFORMATION): BOOL; stdcall;
external advapi32 Name 'CreateProcessWithLogonW'
procedure TForm1.Button2Click(Sender: TObject);
var
STARTUPINF StartupInfoW;
ProcessInf TProcessInformation;
AUser, ADomain, APass, AExe: WideString;
const
LOGON_WITH_PROFILE = $00000001;
LOGON_NETCREDENTIALS_ONLY = $00000002;
begin
FillChar(STARTUPINFO, SizeOf(StartupInfoW), #0);
STARTUPINFO.cb := SizeOf(StartupInfoW);
STARTUPINFO.dwFlags := STARTF_USESHOWWINDOW;
STARTUPINFO.wShowWindow := SW_SHOW;
AUser := edtUser.Text;
ADomain := edtDomain.Text;
APass := edtPass.Text;
AExe := edtExe.Text;
if not CreateProcessWithLogonW(PWideChar(AUser), PWideChar(ADomain),
PWideChar(APass),
LOGON_WITH_PROFILE, nil, PWideChar(AExe),
NORMAL_PRIORITY_CLASS, nil, nil, STARTUPINFO, ProcessInfo) then
RaiseLastOSError;
end;
已經(jīng)測試通過
文章由鄭州北大青鳥整理轉(zhuǎn)載請注明:http://
本文由站河南北大青鳥校區(qū)整編而成,如需了解更多IT資訊類的文章、新聞、課程和學(xué)習(xí)技巧、就業(yè)案例、招生詳情等問題,可以對在線咨詢老師進(jìn)行一對一問答!
推薦資訊
- 怎么在鄭州選擇適合的電腦學(xué)校... 2017-05-18
- 鄭州北大青鳥校區(qū)的畢業(yè)學(xué)員邢志... 2012-10-13
- 河南北大青鳥能力評測... 2012-10-13
- 在河南鄭州怎么選擇學(xué)編程的正規(guī)... 2023-06-07
- 鄭州北大青鳥翔天信鴿北京大學(xué)20... 2015-05-30
熱點資訊
- 如何從外置硬盤中清除感染病毒... 2017-06-11
- 谷歌瀏覽器用戶密碼安全難保... 2017-06-11
- 網(wǎng)站安全性需要注意哪些方面... 2017-06-11
- Linux中服務(wù)器軟件為什么需要編譯... 2017-06-11
- 安卓隱患:防毒軟件無法偵測木馬... 2013-08-06