如何在打开指定路径的文件?(18分)

  • 主题发起人 主题发起人 units
  • 开始时间 开始时间
U

units

Unregistered / Unconfirmed
GUEST, unregistred user!
分数不多了,请教,得解马上给分
 
????<br>ShellExecute??
 
&nbsp;ShellExecute(handle, 'open', 'C:/路径/文件名',nil, nil, sw_ShowNormal);
 
在uses部分加入shellapi<br>ShellExecute(Handle,'open',PChar('路径的文件'),nil, nil, SW_SHOW);<br>
 
很简单,新建一MEMO控件,<br>memo1.Lines.LoadFromFile('c:/1.txt');<br>例,建一MEMO,一按钮<br>unit Unit1;<br><br>interface<br><br>uses<br>&nbsp; Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,<br>&nbsp; Dialogs, StdCtrls;<br><br>type<br>&nbsp; TForm1 = class(TForm)<br>&nbsp; &nbsp; Memo1: TMemo;<br>&nbsp; &nbsp; Button1: TButton;<br>&nbsp; &nbsp; procedure Button1Click(Sender: TObject);<br>&nbsp; private<br>&nbsp; &nbsp; { Private declarations }<br>&nbsp; public<br>&nbsp; &nbsp; { Public declarations }<br>&nbsp; end;<br><br>var<br>&nbsp; Form1: TForm1;<br><br>implementation<br><br>{$R *.dfm}<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>begin<br>memo1.Lines.LoadFromFile('c:/1.txt');<br>end;<br><br>end.<br>
 
在uses部分加入shellapi<br>WinExec('notepad.exe',SW_SHOW);//SW_MAXIMIZE--这个也可以
 
ShellExecute(handle, 'open', '文件名',nil, nil, sw_Normal);<br>不管什么文件都可以打开<br>
 
多谢诸位!
 
后退
顶部