procedure CutOrCopyFiles(pFileList:PcharListStrLen:integerbCopy:Boolean)
type
PDropFiles = ^TDropFiles
TDropFiles = record
pFiles: DWORD
pt: TPoint
fNC: BOOL
fWide: BOOL
end
const DROPEFFECT_COPY = 1DROPEFFECT_MOVE = 2
var hGblFileList: HGLOBALpFileListDate:PbyteHandleDropEffect: UINT
hGblDropEffect: HGLOBALpdwDropEffect: PDWORD
begin
hGblFileList := GlobalAlloc(GMEM_ZEROINIT or GMEM_MOVEABLE or GMEM_SHARE, ListStrLen+Sizeof(TDropFiles))
pFileListDate := GlobalLock(hGblFileList)
PDropFiles(pFileListDate)^.pFiles:=Sizeof(TDropFiles)
PDropFiles(pFileListDate)^.pt.Y:=0
PDropFiles(pFileListDate)^.pt.X:=0
PDropFiles(pFileListDate)^.fNC:=False
PDropFiles(pFileListDate)^.fWide:=False
inc(pFileListDate,Sizeof(TDropFiles)) //Ö¸ÕëºóÒÆ
CopyMemory(pFileListDate,pFileList,ListStrLen)
GlobalUnlock(hGblFileList)
HandleDropEffect := RegisterClipboardFormat('晌瞎Preferred DropEffect ')
hGblDropEffect := GlobalAlloc(GMEM_ZEROINIT or GMEM_MOVEABLE or GMEM_SHARE, sizeof(DWORD))
pdwDropEffect := GlobalLock(hGblDropEffect)
if(bCopy) then
pdwDropEffect^ := DROPEFFECT_COPY
else
pdwDropEffect^ := DROPEFFECT_MOVE
GlobalUnlock(hGblDropEffect)
if OpenClipboard(0) then
begin
EmptyClipboard()
SetClipboardData(HandleDropEffect,hGblDropEffect)
SetClipboardData(CF_HDROP,hGblFileList)
CloseClipboard()
end
else
showmessage( 'ÎÞ瞎谨梁·¨´ò¿ª,¿ÉÄܱ»±ðµÄ³ÌÐòÕ¼Óà ')
end
你的这个问题我来说说:用CopyFile()函数吧。
CopyFile(pchar('c:\123.txt'),pchar('d:\123-备份.txt'),False)
其实作为编程,你可以选择文件并动烂姿态设置文件名:
首先你在form上添加个savefiledialg,并设置这个savefiledialg相关参数,
再在form上添加个openfiledialg ,并设置这个openfiledialg的相关参数。做卖
然后这样编程:
if openfiledialg1.execute then
begin
if savefiledialg1.excetu then
begin
CopyFile(pchar(openfiledialg1.filename),pchar(savefiledialg1.filename),False)
end
end
(以上代饥胡绝码只是随手编写,过程是正确的,但是不保证关键字的字母排列是否正确。)
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)