指定權(quán)限運(yù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)測(cè)試通過(guò)
文章由鄭州北大青鳥(niǎo)整理轉(zhuǎn)載請(qǐng)注明:http://
本文由站河南北大青鳥(niǎo)校區(qū)整編而成,如需了解更多IT資訊類的文章、新聞、課程和學(xué)習(xí)技巧、就業(yè)案例、招生詳情等問(wèn)題,可以對(duì)在線咨詢老師進(jìn)行一對(duì)一問(wèn)答!
推薦資訊
- 怎么在鄭州選擇適合的電腦學(xué)校... 2017-05-18
- 鄭州北大青鳥(niǎo)校區(qū)的畢業(yè)學(xué)員邢志... 2012-10-13
- 河南北大青鳥(niǎo)能力評(píng)測(cè)... 2012-10-13
- 在河南鄭州怎么選擇學(xué)編程的正規(guī)... 2023-06-07
- 鄭州北大青鳥(niǎo)翔天信鴿北京大學(xué)20... 2015-05-30
熱點(diǎn)資訊
- 如何從外置硬盤(pán)中清除感染病毒... 2017-06-11
- 谷歌瀏覽器用戶密碼安全難保... 2017-06-11
- 網(wǎng)站安全性需要注意哪些方面... 2017-06-11
- Linux中服務(wù)器軟件為什么需要編譯... 2017-06-11
- 安卓隱患:防毒軟件無(wú)法偵測(cè)木馬... 2013-08-06