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.

posted @ 2008-05-20 01:07  莫忆往西  阅读(361)  评论(0)    收藏  举报