Delphi使用系统默认程序打开外部文件
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls,shellapi ;
type
TForm1 = class(TForm)
Button1: TButton;
OpenDialog1: TOpenDialog;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
filename:String;
begin
if opendialog1.Execute then
filename:=trim(opendialog1.filename);
ShellExecute(handle,'open',Pchar(filename),nil,nil,SW_SHOWNORMAL);
end;
end.

浙公网安备 33010602011771号