Delphi OpenDialog使用方法

var
  OpenDlg: TOpenDialog;
  strFileName: string;
begin
  OpenDlg := TOpenDialog.Create(nil);
  try
    OpenDlg.Filter := '协议文件(*.EXE)|*.EXE|全部文件(*.*)|*.*';
    OpenDlg.DefaultExt := '*.EXE';
    if OpenDlg.Execute then
    begin
      strFileName := Trim(OpenDlg.FileName);
      if strFileName <> '' then
      begin
        edtProtocolApplication.Text := strFileName;
      end;
    end;
  finally
    FreeAndNil(OpenDlg);
  end;
end;

你可能感兴趣的:(delphi)