很挫的 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)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • 【基础数学】单射、满射和双射的定义、区别[通俗易懂]

    【基础数学】单射、满射和双射的定义、区别[通俗易懂]满射:对任意b,存在a满足f(a)=b~即:值域y是满的,每个y都有x对应,不存在某个y没有x对应的情况~单射:(one-to-onefunction)一对一函数,x不同则y不同~即:没有一个x对应两个y,也没有一个y有对应两个x~双射:既是满射,也是单射~即:每个y都有x对应,而且都是一一对应~…

    2022年6月10日
    119
  • journalctl用法详解

    journalctl用法详解文章目录一、journalctl命令简述二、journalctl常用选项一、journalctl命令简述journalctl[OPTIONS…][MATCHES…]Querythejournal.Flags:–systemShowthesystemjournal–userShowtheuserjournalforthecurrentuser-M–machine=CO

    2022年5月24日
    83
  • view.performClick()触发点击事件

    view.performClick()触发点击事件view.performClick(),主动触发点击

    2022年6月16日
    68
  • 中小型企业局域网设计

    中小型企业局域网设计中小型企业局域网设计                                                        引言 ………………………………………………………………………………2一、公司简介………………………………………………………………………3二、企业需求分析…………………………………………………………………3三、总体设计方案…………………………………

    2022年7月12日
    16
  • 10.2 网页插入背景音乐「建议收藏」

    10.2 网页插入背景音乐「建议收藏」一、bgsound标签简介在网页中可以为某个网页设置背景音乐,使用的是bgsound标签。bgsound是用以插入背景音乐,但只适用于IE浏览器,在Firefox等中未必适用。语法:背景音乐的文件可以是avi、mp3等声音文件。“背景音乐的地址”可以是相对路径,也可以是绝对路径。强烈不推荐使用绝对路径。使用bgsound加入背景音乐与使用embed加入音频不一样,加入音频是有操

    2022年9月13日
    0
  • USB协议详解

    USB协议详解本博客整理自网络,仅供学习参考,如有侵权,联系删除。邮箱:rom100@163.com一个transfer(传输)由一个或多个transaction(事务)构成,一个transaction(事务)由一个或多个packet(包)构成,一个packet(包)由一个或多个sync(域)构成。1.传输数据通信USB的数据通讯首先是基于传输(transfer)的,传输的类型有:中断传输、批量传输…

    2022年6月29日
    38

发表回复

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

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