Take it easy. For Example : uses shellapi; function ExecuteFile(const FileName, Params, DefaultDir: string; ShowCmd: Integer): THandle; var zFileName, zParams, zDir: array[0..79] of Char; begin Result := ShellExecute(Application.MainForm.Handle, nil, StrPCopy(zFileName, FileName), StrPCopy(zParams, Params), StrPCopy(zDir, DefaultDir), ShowCmd); end;調用 :ExecuteFile('c:\office\excel.exe', '', '', SW_SHOW);
win32 下最好用CreateProcess
ShellExecute(Handle,nil,Pchar(Path),nil,nil,1);
即可。
For Example :
uses shellapi;
function ExecuteFile(const FileName, Params, DefaultDir: string;
ShowCmd: Integer): THandle;
var
zFileName, zParams, zDir: array[0..79] of Char;
begin
Result := ShellExecute(Application.MainForm.Handle, nil,
StrPCopy(zFileName, FileName), StrPCopy(zParams, Params),
StrPCopy(zDir, DefaultDir), ShowCmd);
end;調用 :ExecuteFile('c:\office\excel.exe', '', '', SW_SHOW);