Delphi 文件、目录等常用操作函数 - delphi - gliethttp

来源:互联网 发布:听杨绛谈往事知乎 编辑:程序博客网 时间:2024/04/29 20:17
Delphi 文件、目录等常用操作函数 - delphi - gliethttp[ http://blog.chinaunix.net/u1/38994/showart_303315.html ] ... Delphi 文件、目录等常用操作函数

1.获取exe程序的相对路径(不含"/")

ShowMessage(ExtractFileDir(Application.Exename));//如: D:/gliethttp

2.获取exe程序的相对路径(含"/")
ShowMessage(ExtractFilePath(Application.Exename));//如: D:/gliethttp/

3.打开指定文件:首先,uses ShellAPI;然后,调用如下函数

ShellExecute(handle,'open','c:/gliethttp.c',nil,nil,sw_shownormal);

或 ShellExecute(handle,'open','c:/gliethttp.exe',nil,nil,sw_shownormal);
4.Memo常用消息

滚到底:SendMessage(Memo1.Handle,EM_LINESCROLL,0,Memo1.Lines.Count);

获取当前最顶行的行号:Result:=SendMessage(Memo1.Handle,EM_GETFIRSTVISIBLELINE,0,0);

获取当前矩形下容纳的行数:FontHeight:Integer;
ARect:TRect;
begin
FontHeight:=abs(Memo1.Font.Height);
SendMessage(Memo1.Handle,EM_GETRECT,0,DWord(@ARect));
Result:=(ARect.Bottom-ARect.Top) div FontHeight;

...
原创粉丝点击