一个送分的问题哦!

dongdong_daddy 2002-05-20 10:22:30
为什么我用ShellExecute(handle, nil,pchar('myfile'), nil, nil,SW_SHOWNORMAL);打不开myfile.txt文件呢?
好像要打开一个txt文件,不用memo1.Lines.LoadFromFile();还有一种方法或函数
不知是什么啊?
...全文
25 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
dongdong_daddy 2002-05-24
  • 打赏
  • 举报
回复
多谢各位大虾!
eagle123 2002-05-20
  • 打赏
  • 举报
回复
用ShellExecute(handle, 'open',pchar('myfile'), nil, nil,SW_SHOWNORMAL)试试,可以用记事本打开
如果你想在程序中读取文本内容的话可以这样
procedure TForm1.Button1Click(Sender: TObject);
const maxbuf=10;
var f:Tfilestream ;
buf:array[0..maxbuf-1] of char;
i:integer;
thecount:integer;
begin
f:=Tfilestream.Create('c:\a.txt',fmOpenRead);
thecount:=(f.size div maxbuf);
for i:=1 to thecount do
begin
f.ReadBuffer(buf,10);
memo1.Lines.Add(buf);
end;
f.ReadBuffer(buf,f.size-thecount*maxbuf);
memo1.Lines.Add(buf);
end;
delphi0302 2002-05-20
  • 打赏
  • 举报
回复
uses ShellAPI

ShellExecute(handle,'open','myfile.txt',nil,nil,SW_ShowNormal);
zkking 2002-05-20
  • 打赏
  • 举报
回复
二楼正解
becky_hy 2002-05-20
  • 打赏
  • 举报
回复
在uses 里包含ShellAPI,然后:
ShellExecute(handle,'open','myfile.txt',nil,nil,SW_ShowNormal);
DELPHI6下编译通过
lxpbuaa 2002-05-20
  • 打赏
  • 举报
回复
WinExec('NotePad H:\Diary\Julie.txt',SW_SHOW);


—————————————————————————————————
MaximStr := '宠辱不惊,看庭前花开花落,去留无意;
毁誉由人,望天上云卷云舒,聚散任风。';
if Not Assigned(I) then
I := TI.Create(Nil);
I.Maxim := MaximStr;
I.Explain := '假如上述代码中出现“OA”等字样,删除它们';
I.Desire := '加不加分随你';
—————————————————————————————————


       

5,388

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧