| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1533 人关注过本帖
标题:用windows的DLL接口编写copy程序
只看楼主 加入收藏
sonbo1986
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2009-9-18
结帖率:0
收藏
已结贴  问题点数:20 回复次数:4 
用windows的DLL接口编写copy程序
用windows的DLL接口编写copy程序,
请教如何编写程序实现。
搜索更多相关主题的帖子: 编写 接口 DLL windows 
2009-09-18 12:18
东海一鱼
Rank: 13Rank: 13Rank: 13Rank: 13
等 级:贵宾
威 望:48
帖 子:757
专家分:4760
注 册:2009-8-10
收藏
得分:0 
很简单

include  windows.h                                    ;常用数据结构、类型定义
include  kernel32.inc                                 ;CopyFile的包含文件头

includelib kernel32.lib                               ;CopyFile的实现,由于不是静态库。实际上这里会被编译程序构造为'PE'导入表         
.data
    SrcFile  db 'c:\1.txt',0                          ;源文件路径  
    DestFile db 'd:\11.txt',0                         ;目标文件路径

.........
invoke CopyFile,offset SrcFile,offset DestFile,FALSE   ;调用函数,完成Copy
..........

MSDN具体说明:
BOOL WINAPI CopyFile(
  __in  LPCTSTR lpExistingFileName,
  __in  LPCTSTR lpNewFileName,
  __in  BOOL bFailIfExists
);
 
Parameters
lpExistingFileName [in]  
The name of an existing file.  
 
In the ANSI version of this function, the name is limited to MAX_PATH characters. To extend this limit to 32,767 wide characters, call the Unicode version of the function and prepend "\\?\" to the path. For more information, see Naming a File.
 
If lpExistingFileName does not exist, CopyFile fails, and GetLastError returns ERROR_FILE_NOT_FOUND.
 
lpNewFileName [in]  
The name of the new file.  
 
In the ANSI version of this function, the name is limited to MAX_PATH characters. To extend this limit to 32,767 wide characters, call the Unicode version of the function and prepend "\\?\" to the path. For more information, see Naming a File.
 
bFailIfExists [in]  
If this parameter is TRUE and the new file specified by lpNewFileName already exists, the function fails. If this parameter is FALSE and the new file already exists, the function overwrites the existing file and succeeds.
 
Return Value
If the function succeeds, the return value is nonzero.
 
If the function fails, the return value is zero. To get extended error information, call GetLastError.
 


举世而誉之而不加劝,举世而非之而不加沮,定乎内外之分,辩乎荣辱之境,斯已矣。彼其于世未数数然也。
2009-09-18 13:01
sonbo1986
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2009-9-18
收藏
得分:0 
谢谢兄弟,我看不明白,你能不能把完整的实现代码贴出来。
2009-09-20 17:52
东海一鱼
Rank: 13Rank: 13Rank: 13Rank: 13
等 级:贵宾
威 望:48
帖 子:757
专家分:4760
注 册:2009-8-10
收藏
得分:20 
.386
.model flat,stdcall
option casemap:none

include  windows.inc                                    ;常用数据结构、类型定义
include  kernel32.inc                                 ;CopyFile的包含文件头
 
includelib kernel32.lib                              
.data
    SrcFile  db 'c:\1.txt',0                          ;源文件路径   
    DestFile db 'd:\11.txt',0                         ;目标文件路径
.code
_start:
    invoke CopyFile,offset SrcFile,offset DestFile,FALSE   ;调用函数,完成Copy
    cmp eax,0
    jz @F
    jmp over
@@:
    mov eax,1
over:
    invoke ExitProcess,eax
end _start


举世而誉之而不加劝,举世而非之而不加沮,定乎内外之分,辩乎荣辱之境,斯已矣。彼其于世未数数然也。
2009-09-20 19:25
sonbo1986
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2009-9-18
收藏
得分:0 
兄弟太感谢,我们学校开了这门课,一点也不懂,
你帮了我大忙了。
2009-09-20 20:23
快速回复:用windows的DLL接口编写copy程序
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.011780 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved