您的位置:網(wǎng)站首頁 > 電器維修資料網(wǎng) > 正文 >
通過一定權(quán)限運行程序
來源: 日期:2013-11-20 18:37:42 人氣:標簽:
在操作系統(tǒng)中每個程序的運行都有自己的特定權(quán)限,權(quán)限越大,它能涉及的范圍就越廣。
我們可以通過以下代碼指定權(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;
【看看這篇文章在百度的收錄情況】
相關(guān)文章
- 上一篇: 電腦中了木馬怎樣快速清除
- 下一篇: 詳解ARP命令