易截截图软件、单文件、免安装、纯绿色、仅160KB

Delphi 创建目录及写日志文件


Delphi 创建目录及写日志文件
var
TF: TextFile;
LogFile: string;
txt :string;
sysDir:string;
//创建按钮
procedure TForm1.Button1Click(Sender: TObject);
begin
sysDir:=extractfilepath(application.ExeName );
if not directoryexists(sysdir+'log\') then
createdir(sysdir+'log\');
logfile:=sysdir+'log\'+formatdatetime('yyyymmdd',now)+'.txt';
end;
//写日志按钮
procedure TForm1.Button2Click(Sender: TObject);
begin
//assignfile(logfile,'log.txt');
AssignFile(tf,logfile);
if fileexists(logfile) then
append(tf)
else
rewrite(tf);
writeln(tf,'123');
closefile(tf);
end;


相关文档:

delphi 注册 com 对象的方法

delphi 注册 com 对象的方法
procedure TForm1.Button3Click(Sender: TObject);
var
 Sd: TSecurityDescriptor;
 begin
   InitializeSecurityDescriptor(@Sd, SECURITY_DESCRIPTOR_REVISION);
    SetSecurityDescriptorDacl(@Sd, true, Nil, false);
    RegSe ......

Delphi 相关记录

1、TStringList支持的最大行数是多少?(http://topic.csdn.net/t/20060209/14/4547405.html)
楼主结论:“TStringList的LoadfromFile函数应该只能读取15万行以内的数据,但TStringList和TList的Add函数可以加到几百万行(甚至更多)也不会出错。程序出错的原因应该是Add非法内存指针导致的,正如tanlim(求学者) &nb ......

delphi字符串转换为char数组

var
  arrChar : array [0..4] of Char;
  b : Byte;
  s : string;
begin
  s := 'Test';
  Move(Pointer(s)^, arrChar, Length(s));   //string to array of char
  ShowMessage(arrChar);
  b := Ord(s[1]);   //First byte string to one single byte ......

unix C 、delphi的多语言文本字符换行的问题

今天项目组发生一个事情就是,后台aix上对多语言文本(英语+汉字)换行问题搞不太清楚。
最早前台的多字符的代码我检查了一下(按照0-128以外算中文的代码)发现不是安全的代码。
(delphi 7.0)
delphi安全的混合字符的操作方法是:
在strsUtils单元中
leftstr
MidStr
Rightstr
aix下是: ......

Delphi中的数组

不论数组元素是什么类型,静态数组的局部变量总会在栈上分配。如果堆栈大小不够将会导致异常。下例暗藏着一个危险的bug
procedure stackover;
var
s:array [0..4100] of string[255];
begin
end; 
delphi默认栈最大为$100000字节,上例中的栈上分配的大侠为256*4100>$10000。测试必然会出现异常Stack overf ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号