解决不了,着急!! 我在本地磁盘下例如D:\DATA下有大量的word文件,我想通过delphi做个小程序直接可以调用并打开文件,而不必在文件夹下面找,通过变量赋值的文件名,直接打开需要查找的文件,起到浏览作用,我用了shellexecute,但是没有搞定,各位高手,有好的办法教给我,最好有源代码,不够可以再加分。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 //拖曳一 Button1 和 Edit1 uses ShellApi;procedure TForm1.Button1Click(Sender: TObject);begin with TOpenDialog.Create(Self) do begin InitialDir := ExtractFileDir(Application.ExeName); Filter := '*.doc(Word files)|*.doc|*.*(All files)|*.*'; if Execute then begin Edit1.Text := FileName; ShellExecute(Handle, 'open', PChar(Edit1.Text), nil, PChar(ExtractFileDir(Edit1.Text)), SW_SHOW); end; end;end;不知行吗? 你什么意思啊?上面那个就是你输入文件名字直接打开啊你要不这样做个变历data路径下的所有word文件名,然后保存到比如到listbox或者treeview里面有点想资源管理器啊你这么做没有意思啊 //设置你的变量名为name1,为string型号,存储的名称含扩展名!~uses ShellApi;procedure TForm1.Button1Click(Sender: TObject);var fullname:string;begin fullname:='D:\DATA\'+name1;//name1为你的变量 ShellExecute(Handle, 'open', PChar(fullname), nil, PChar(ExtractFileDir(fullname)),SW_SHOW);end; 其实YYQQ(阿鱼) 的思路是对的!(·¥·) 赌博 把分全输光了 现在问一个有难度的问题 Pascal for循环习题算法求解!!!!10分相赠!! 请网上的各位帮忙给解决一个问题谢谢!!!!!!!!!!!!! 语言问题,EXTERNALSYM有什么用? 提个问题!!在线等答案!! 怎样判断鼠标进入了toolbutton区域? 判断对象是否存在?(解决问题马上给分) 在ORACLE中不能使用关联吗? 很简单的一个问题,但我不知我忽略了什么? 如果根据句柄获取该程序的窗体边框的高度和宽度? 紧急求助!!! 继续讨论
ShellApi;
procedure TForm1.Button1Click(Sender: TObject);
begin
with TOpenDialog.Create(Self) do
begin
InitialDir := ExtractFileDir(Application.ExeName);
Filter := '*.doc(Word files)|*.doc|*.*(All files)|*.*';
if Execute then
begin
Edit1.Text := FileName;
ShellExecute(Handle, 'open', PChar(Edit1.Text), nil,
PChar(ExtractFileDir(Edit1.Text)), SW_SHOW);
end;
end;
end;不知行吗?
上面那个就是你输入文件名字
直接打开啊
你要不这样
做个变历data路径下的所有word文件名,然后保存到比如到listbox或者treeview里面
有点想资源管理器啊
你这么做没有意思啊
uses
ShellApi;procedure TForm1.Button1Click(Sender: TObject);
var
fullname:string;
begin
fullname:='D:\DATA\'+name1;//name1为你的变量
ShellExecute(Handle, 'open', PChar(fullname), nil,
PChar(ExtractFileDir(fullname)),SW_SHOW);
end;
(·¥·)