【delphi开源代码栏目提醒】:本文主要为网学会员提供frm_Openexe.pas,希望对需要frm_Openexe.pas网友有所帮助,学习一下!
unit frm_Openexe;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls,shellAPI, XPMan, FileCtrl;
type
TFrmExeOpen = class(TForm)
BtnOpen: TButton;
BtnClose: TButton;
GroupBox1: TGroupBox;
FileList: TFileListBox;
DirectoryLBx: TDirectoryListBox;
DriveCBx: TDriveComboBox;
procedure BtnOpenClick(Sender: TObject);
procedure BtnCloseClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
FrmExeOpen: TFrmExeOpen;
implementation
{$R *.dfm}
procedure TFrmExeOpen.BtnOpenClick(Sender: TObject);
var
sr: TSearchRec;
FileAttrs: Integer;
dirchar:array[0..255] of char;
begin
dirchar:='';
if trim(FileLIst.FileName) <> '' then
begin
FileAttrs := faAnyFile;
strcat(dirchar,pchar(FileList.FileName));
if findfirst(dirchar,FileAttrs,sr)=0 then
shellexecute(application.Handle,nil,dirchar,nil,nil,sw_shownormal) //执行计算器
程序 else
showmessage('该文件不存在!!');
end;
end;
procedure TFrmExeOpen.BtnCloseClick(Sender: TObject);
begin
Close;
end;
end.