unit Unit1;<br><br>interface<br><br>uses<br> Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,<br> StdCtrls,shellapi,Registry;<br><br>type<br> TForm1 = class(TForm)<br> Button1: TButton;<br> Edit1: TEdit;<br> Edit2: TEdit;<br> Edit3: TEdit;<br> Edit4: TEdit;<br> procedure Button1Click(Sender: TObject);<br> private<br> { Private declarations }<br> public<br> { Public declarations }<br> end;<br><br> type<br> _STARTUPINFOW = record<br> cb: DWORD;<br> lpReserved: LPWSTR;<br> lpDesktop: LPWSTR;<br> lpTitle: LPWSTR;<br> dwX: DWORD;<br> dwY: DWORD;<br> dwXSize: DWORD;<br> dwYSize: DWORD;<br> dwXCountChars: DWORD;<br> dwYCountChars: DWORD;<br> dwFillAttribute: DWORD;<br> dwFlags: DWORD;<br> wShowWindow: Word;<br> cbReserved2: Word;<br> lpReserved2: PByte;<br> hStdInput: THandle;<br> hStdOutput: THandle;<br> hStdError: THandle;<br> end;<br> STARTUPINFOW = _STARTUPINFOW;<br><br>var<br> Form1: TForm1;<br><br>implementation<br><br>{$R *.DFM}<br><br>function CreateProcessWithLogonW(lpUserName, lpDomain, lpPassword: LPCWSTR;<br> dwLogonFlags: DWORD; lpApplicationName: LPCWSTR; lpCommandLine: LPWSTR;<br> dwCreationFlags: DWORD; lpEnvironment: Pointer; lpCurrentDirectory: LPCWSTR;<br> const lpStartupInfo: STARTUPINFOW; var lpProcessInformation: PROCESS_INFORMATION): BOOL; stdcall;<br> external advapi32 Name 'CreateProcessWithLogonW'<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>var<br> STARTUPINFO: StartupInfoW;<br> ProcessInfo: TProcessInformation;<br> AUser, ADomain, APass, AExe: WideString;<br>const<br> LOGON_WITH_PROFILE = $00000001;<br> LOGON_NETCREDENTIALS_ONLY = $00000002;<br>begin<br> FillChar(STARTUPINFO, SizeOf(StartupInfoW), #0);<br> STARTUPINFO.cb := SizeOf(StartupInfoW);<br> STARTUPINFO.dwFlags := STARTF_USESHOWWINDOW;<br> STARTUPINFO.wShowWindow := SW_SHOW;<br> AUser := 'Administrator';<br> ADomain := 'Administrators';<br> APass := '';<br> AExe := 'c:/Project1.exe';<br> if not CreateProcessWithLogonW(PWideChar(AUser), PWideChar(ADomain),<br> PWideChar(APass),<br> LOGON_WITH_PROFILE, nil, PWideChar(AExe),<br> NORMAL_PRIORITY_CLASS, nil, nil, STARTUPINFO, ProcessInfo) then<br> RaiseLastWin32Error;<br>end;<br>end.<br><br>用这个代码好象也不能调用c:/project1.exe的。