+ -
当前位置:首页 → 问答吧 → delphi中判断文件是否能打开

delphi中判断文件是否能打开

时间:2011-09-23

来源:互联网

如下代码
shellexecute(handle,'open',pchar('\\192.168.0.6\tz$\aa.pdf'),nil,nil,sw_shownormal);
当客户端机器没有安装pdf阅读器时,执行以上代码没反应,请问这时该如何提示‘无法打开该文件’?

作者: coderee   发布时间: 2011-09-23

我机器上没装,不过思路是
LZ 运行regedit 寻找acrobat的安装路径,然后记下这个键值,每次运行程序时,先读取这个键值,有即可运行pdf

作者: funxu   发布时间: 2011-09-23

一个读取键值的例子
procedure TForm1.Button18Click(Sender: TObject);
var reg:Tregistry;
 KeyList: TStringList;
 i: Integer;
begin
reg:=Tregistry.create;
KeyList := TStringList.Create;
reg.RootKey := HKEY_LOCAL_MACHINE;
reg.openkey('HARDWARE\DEVICEMAP\SERIALCOMM', False);
reg.GetValueNames(KeyList);
for i := 0 to KeyList.Count - 1 do
begin
 ShowMessage(KeyList[i]);
 ShowMessage(reg.ReadString(KeyList[i]));
end;
reg.CloseKey;
reg.free;
KeyList.Free;
end;

作者: funxu   发布时间: 2011-09-23

Tregistry类需引用哪个单元?

作者: coderee   发布时间: 2011-09-23