unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls,ShellAPI,StrUtils;
type
TForm1 = class(TForm)
OpenDialog1: TOpenDialog;
Button2: TButton;
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button2Click(Sender: TObject);
var
s:string;
begin
if OpenDialog1.Execute then
begin
s:=OpenDialog1.FileName;
end;
//處理檔案路徑中帶問號,逗號
s:=AnsiReplaceText(s,'?','"?"');//問號
s:=AnsiReplaceText(s,',','","');//逗號
s:=AnsiReplaceText(s,',','","');//逗號
s:='"'+s+'"';//處理帶空格的情況
ShellExecute(0, 'open', 'AcroRd32.exe', PChar(s), '', SW_SHOWMAXIMIZED);
end;
end.
為什么程式運行之后會出現下面的錯誤?
uj5u.com熱心網友回復:
1、保存檔案時,盡可能地在檔案名中,不要使用特殊字符;2、檔案名已經有(漢字雙位元組)符號,時直接用原檔案名可以打開。
你的問題是,打開檔案時,將原檔案名中的雙位元組的符號,換成單字符的符號。修改了檔案名。出現打開一個不存在的檔案錯誤。
uj5u.com熱心網友回復:
procedure TForm1.Button2Click(Sender: TObject);
var s:string;
begin
if OpenDialog1.Execute then
begin
ShellExecute(0, 'open', 'AcroRd32.exe', PChar(OpenDialog1.FileName), '', SW_SHOWMAXIMIZED);
END;
end;
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/47744.html
上一篇:FastReport 問題
