让ASP组件以管理员身份运行一程序时初始化错误 ( 积分: 50 )

  • 主题发起人 主题发起人 bo717
  • 开始时间 开始时间
B

bo717

Unregistered / Unconfirmed
GUEST, unregistred user!
这是我做的ASP组件,要这个组件以管理员身份运行一个程序
出错:应用程序正常初始化(Oxc0000142)失败.请单击"确定",终止应用程序.

procedure TTestObject.CP;
var
STARTUPINFO: StartupInfoW;
ProcessInfo: 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 := 'Administrator';
ADomain := 'Administrators';
APass := 'XXXX';
AExe := 'F:/Project1.exe';
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;
 
后退
顶部