很挫的 SHFileOperation 用法 2011-07-18 11:42「建议收藏」

很挫的 SHFileOperation 用法 2011-07-18 11:42「建议收藏」今天编写一个局域网文件拷贝的demo。其中有一个SHFileOperation的用法,这个函数有个参数SHFILEOPSTRUCT。查看msdn有如下解释:pFromAddressofa

大家好,又见面了,我是你们的朋友全栈君。

今天编写一个局域网文件拷贝的demo 。其中有一个 SHFileOperation 的用法,这个函数有个参数SHFILEOPSTRUCT。查看msdn有如下解释:

pFromAddress of a buffer to specify one or more source file names. These names must be fully qualified paths. Standard Microsoft MS-DOS wild cards, such as “*”, are permitted in the file-name position. Although this member is declared as a null-terminated string, it is used as a buffer to hold multiple file names.
Each file name must be terminated by a single NULL character. An additional NULL character must be appended to the end of the final name to indicate the end of pFrom.pToAddress of a buffer to contain the name of the destination file or directory. This parameter must be set to NULL if it is not used. Like pFrom, the pTo member is also a double-null terminated string and is handled in much the same way. However, pTo must meet the following specifications.

Wildcard characters are not supported.

Copy and Move operations can specify destination directories that do not exist and the system will attempt to create them. The system normally displays a dialog box to ask the user if they want to create the new directory. To suppress this dialog box and have the directories created silently, set the FOF_NOCONFIRMMKDIR flag in fFlags.

For Copy and Move operations, the buffer can contain multiple destination file names if the fFlags member specifies FOF_MULTIDESTFILES.

Pack multiple names into the string in the same way as for pFrom.

Use only fully-qualified paths. Using relative paths will have unpredictable results.  

明白否,不明白看在线msdn的解释

pFrom

Type: LPCTSTR

Note  This string must be double-null terminated.

A pointer to one or more source file names. These names should be fully-qualified paths to prevent unexpected results.

Standard MS-DOS wildcard characters, such as “*”, are permitted only in the file-name position. Using a wildcard character elsewhere in the string will lead to unpredictable results.

Although this member is declared as a single null-terminated string, it is actually a buffer that can hold multiple null-delimited file names. Each file name is terminated by a single NULL character. The last file name is terminated with a double NULL character (“\0\0”) to indicate the end of the buffer.

pTo

Type: LPCTSTR

Note  This string must be double-null terminated.

A pointer to the destination file or directory name. This parameter must be set to NULL if it is not used. Wildcard characters are not allowed. Their use will lead to unpredictable results.

Like pFrom, the pTo member is also a double-null terminated string and is handled in much the same way. However, pTo must meet the following specifications:

  • Wildcard characters are not supported.
  • Copy and Move operations can specify destination directories that do not exist. In those cases, the system attempts to create them and normally displays a dialog box to ask the user if they want to create the new directory. To suppress this dialog box and have the directories created silently, set the FOF_NOCONFIRMMKDIR flag in fFlags.
  • For Copy and Move operations, the buffer can contain multiple destination file names if the fFlags member specifies FOF_MULTIDESTFILES.
  • Pack multiple names into the pTo string in the same way as for pFrom.
  • Use fully-qualified paths. Using relative paths is not prohibited, but can have unpredictable results.

这样写就行 

string strSrc(“F:\\tools\\WINXPSP3.GHO”);
 strSrc += ‘\0’;

 string strDesc(“\\\\192.168.1.11\\test“);
 strDesc += ‘\0’;

 CopyFolder( strSrc, strDesc );
这样写就不行CopyFolder( std::string(“D:\\2.txt\0”), std::string(“e:\\3.txt\0”) );

饿的那个神啊。记住了这很挫的方式。

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/154790.html原文链接:https://javaforall.net

(0)
上一篇 2022年7月1日 上午9:16
下一篇 2022年7月1日 上午9:36


相关推荐

  • 什么是ARP欺骗_ARP欺骗防范

    什么是ARP欺骗_ARP欺骗防范ARP欺骗的本质是把虚假的IP-MAC映射关系通过ARP报文发给主机,让主机把虚假的IP-MAC映射存入ARP缓存表(可能是IP地址错误,也可能是MAC地址错误),让其无法正确发送数据漏洞的根源ARP协议是无连接操作系统收到ARP请求或响应后无法确认senderMAC和senderIP真假ARP欺骗伪造网关攻击者B伪造ARP报文(senderIP地址是网关的,senderMAC地址不是网关的),发送给网段内的主机A,那么主机A就会把网关的ip地址和伪造的mac地址缓存到arp缓.

    2025年7月3日
    5
  • 分布式事务管理原理 TCC和LCN 分布式详解

    分布式事务管理原理 TCC和LCN 分布式详解最近笔者在面试过程中发现 分布式的微服务开发越来越广泛了 越来越多的企业在面试时都需要有微服务的经验 那么在谈到微服务的过程中 很多的面试官都会问到一个问题 有没有接触过分布式事务管理 怎么实现分布式事务管理 那在这里就先要理解一下 什么是分布式事务管理 在单系统中 事务管理想必大家都很清楚 举个栗子 银行转账的过程中 张三的余额有 100 元 李四 0 元 张三要转 50 元给李四

    2026年3月18日
    2
  • ASP.NET页面事件:顺序与回传详解

    当页面被提交请求第一个方法永远是构造函数。您可以在构造函数里面初始一些自定义属性或对象,不过这时候因为页面还没有被完全初始化所以多少会有些限制。特别地,您需要使用HttpContext对象。当前可以使

    2021年12月26日
    39
  • spring+mybatis数据源切换【service层以及controller层】

    spring+mybatis数据源切换【service层以及controller层】

    2021年5月15日
    132
  • vld 使用

    vld 使用http vld codeplex com documentatio 最近发现用 vs2013 vld 的版本是 2 3 发现 nbsp 检测不了 Visual nbsp Leak nbsp Detector nbsp Version nbsp 2 3 nbsp installed No nbsp memory nbsp leaks nbsp detected Visual nbsp Leak nbsp Detector nbsp is nbsp now nbsp exiting 网上也已经证实了这个 bug 于

    2026年3月17日
    2
  • Java 中常见的 RPC 协议

    Java 中常见的 RPC 协议hessian(Dubbo使用的是dubbo协议是优化过的hessian协议)thrift(apache提供的跨语言的rpc协议)protobuf(google提供的跨语言的rpc协议)

    2022年5月12日
    41

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号