找回密码
 加入
搜索
查看: 1951|回复: 4

关于调用系统复制文件框的问题

[复制链接]
发表于 2009-2-24 15:15:49 | 显示全部楼层 |阅读模式
关于调用系统复制文件框的问题.
我发现不能使用中文或者过长的路径,好象是出在 Char  这里了,使用了几个如 int  long 等,也都不对,又不知道用何替代,请各位指点一下
_fileCopy("d:\system\系统.iso", "c:\drivers\系统.iso")
 
Func _filecopy($source, $dest)
 
    Local $SHFILEOPSTRUCT, $source_struct, $dest_struct
        
    $SHFILEOPSTRUCT = DllStructCreate("hwnd hWnd;uint wFunc;ptr pFrom;ptr pTo;int fFlags;int fAnyOperationsAborted;ptr hNameMappings;ptr lpszProgressTitle")
 
    $source_struct = DllStructCreate("char[" & StringLen($source) + 2 & "]")
    DllStructSetData($source_struct, 1, $source)
    DllStructSetData($source_struct, 1, 0, StringLen($source) + 2)
     $dest_struct = DllStructCreate("char[" & StringLen($dest) + 2 & "]")
    DllStructSetData($dest_struct, 1, $dest)
    DllStructSetData($dest_struct, 1, 0, StringLen($dest) + 2)
     DllStructSetData($SHFILEOPSTRUCT, "hWnd", 0)
    DllStructSetData($SHFILEOPSTRUCT, "wFunc", 0x0002)
    DllStructSetData($SHFILEOPSTRUCT, "pFrom", DllStructGetPtr($source_struct))
    DllStructSetData($SHFILEOPSTRUCT, "pTo", DllStructGetPtr($dest_struct))
    DllStructSetData($SHFILEOPSTRUCT, "fFlags",  0x0010)
    DllCall("shell32.dll", "int", "SHFileOperation", "ptr", DllStructGetPtr($SHFILEOPSTRUCT))
EndFunc


[ 本帖最后由 wyx5 于 2009-2-24 16:20 编辑 ]
发表于 2009-2-24 20:15:28 | 显示全部楼层
之所以长度加2的原因是要兼容宽字符~
仔细看下哪个类型是宽字符吧~就在DllStructCreate帮助里面。
 楼主| 发表于 2009-2-25 09:16:40 | 显示全部楼层
原帖由 pusofalse 于 2009-2-24 20:15 发表
之所以长度加2的原因是要兼容宽字符~
仔细看下哪个类型是宽字符吧~就在DllStructCreate帮助里面。



好象不是这个原因啊,如果我把 系统.ISO  改成 英文或者数字的文件名,路径不是很长的话,就可以复制的.
发表于 2009-2-25 09:58:33 | 显示全部楼层
除了char要改为wchar外,函数也调用错了。。。- -||| SHFileOperationW
另外DllStructSetData($source_struct, 1, 0, StringLen($source) + 2)两句是多余的吧?~
 楼主| 发表于 2009-2-25 11:23:34 | 显示全部楼层
原帖由 pusofalse 于 2009-2-25 09:58 发表
除了char要改为wchar外,函数也调用错了。。。- -||| SHFileOperationW
另外DllStructSetData($source_struct, 1, 0, StringLen($source) + 2)两句是多余的吧?~


不多余啊!你编译下看看就知道了~~
麻烦大家帮帮忙啊!!!!!!
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-9-23 07:26 , Processed in 0.077919 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表