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

Delphi中实现文件拷贝的三种方法

Delphi中实现文件拷贝的三种方法
1.调用API函数
procedure CopyFile(fromFileName,ToFileName:string);
var
f1,f2:file;
Begin
AssignFile(f1,fromFileName); file://指定源文件名
AssignFile(f2,ToFileName); file://指定目标文件名
Reset(f1);
Try
Rewrite(f2);
Try
If Lzcopy(TfileRec(f1).handle,TfileRec(f2).Handle)<0
Then
Raise EinoutError.creat('文件复制错误')
Finally
CloseFile(f2); file://关闭 f2
End;
Finally
Until length(sLine)<=0;
End;
End;
2.文件流
procedure copyfile;
var f1,f2: tfilestream ;
begin
f1:=Tfilestream.Create(sourcefilename,fmopenread);
try
f2:=Tfilestream.Create(targetfilename,fmopenwrite or fmcreate);
try
f2.Copyfrom(f1,f1.size);
finally
f2.Free;
end;
finally
f1.Free;
end;
end;
3.利用内存块读写buffer实现
Procudure FileCopy(const fromfile,Tofile:string);
Var
F1,F2:file;
NumRead,Numwritten:word;
Buf:array [1..2048] of char;
Begin
AssignFile(F1,fromfile);
Reset(F1,1);
AssignFile(F2,Tofile);
Rewrite(F2,1);
Repeat
BlockRead(F1,buf,sizeof(buf),NumRead);
BlockWrite(F2,buf,Numread,NumWritten);
Until (NumRead=0) or (NumWritten<>NumRead);
CloseFile(F1);
CloseFile(F2);
End;


相关文档:

javascript中调用delphi函数


以下是test.htm页的内容
首先定义一个插件对象
 
<object id="Mapupload" name="Mapupload" width="0" height="0" classid="clsid:045FA9B9-B373-4D4C-AE76-128A19A4B6AE">
</object>
<script type="text/javascript">
//此函数打开activexform窗体并为activ ......

Delphi日期函数

所在单元: DateUtils
Day 开头的函数
1、DayOf()
描述: 使用 DateOf 函数用来把一个 TDateTime 类型的变量转变成一个 只带有日期的 TDateTime 类型变量。 例如: showmessage(DateTimetostr(dateof(now()))); 你得到的是 2003/03/19 而 showmessage(DateTimetostr((now()))); 得到的是
2、DateTimeTostr()
描述: Da ......

Delphi to Excel 一些方法

一)   使用动态创建的方法   
  
  首先创建   Excel   对象,使用ComObj: 
  var   ExcelApp:   Variant; 
  ExcelApp   :=   CreateOleObject(   'Excel.Application'  ......

Delphi在Vasta/win 7下获取权限

毕竟Win32程序的开发,Delphi还是有顽强的生命力的。
操作步骤如下:
1.建立 res 文件
建立一个文本文件,名字可以自己起,我这里叫:UAC.manifest,内容:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
......

Delphi操作注册表的一般步骤

Delphi操作注册表步骤如下:
-------------------------------------
1)在Uses中添加Registry单元;
2)声明TRegistry对象;
3)创建TRegistry对象;
4)指定根键;
----------------try------------------
5)打开需要操作的主键;
6)读写操作;
7)保存并关闭主键;
--------------finally----------------
......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号