今天编写一个局域网文件拷贝的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") );

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

很挫的 SHFileOperation 用法 2011-07-18 11:42的更多相关文章

  1. 日本IT行业劳动力缺口达22万 在日中国留学生迎来就业好时机 2017/07/18 11:25:09

    作者:倪亚敏 来源:日本新华侨报 发布时间:2017/07/18 11:25:09     据日本政府提供的数据,日本2018年应届毕业生的“求人倍率”已经达到了1.78倍.换言之,就是100名大学生 ...

  2. 2021.07.18 P2290 树的计数(prufer序列、组合数学)

    2021.07.18 P2290 树的计数(prufer序列.组合数学) [P2290 HNOI2004]树的计数 - 洛谷 | 计算机科学教育新生态 (luogu.com.cn) 重点: 1.pru ...

  3. [CareerCup] 18.11 Maximum Subsquare 最大子方形

    18.11 Imagine you have a square matrix, where each cell (pixel) is either black or white. Design an ...

  4. [18/11/11] java标识符及变量

    一.标识符规范 1.必须以字母.下划线 .美元符号开头. 即数字不能作为开头,其它位随便 2.不可以是java关键字(即保留字),  如static .class.new 等 .    注:int 年 ...

  5. XPath语法 在C#中使用XPath示例 【转http://www.cnblogs.com/yukaizhao/archive/2011/07/25/xpath.html】非常详细的文章

    XPath语法 在C#中使用XPath示例   XPath可以快速定位到Xml中的节点或者属性.XPath语法很简单,但是强大够用,它也是使用xslt的基础知识. 示例Xml: <?xml ve ...

  6. 摘自(http://www.ruanyifeng.com/blog/2011/07/linux_load_average_explained.html)

    理解Linux系统负荷   作者: 阮一峰 一.查看系统负荷 如果你的电脑很慢,你或许想查看一下,它的工作量是否太大了. 在Linux系统中,我们一般使用uptime命令查看(w命令和top命令也行) ...

  7. 在不开启事件循环的线程中使用QTimer(QThread::run函数自带事件循环,在构造函数里创建线程,是一种很有意思的线程用法) good

    引入 QTimer是Qt自带的定时器类,QTimer运行时是依赖于事件循环的,简单来说,在一个不开启事件循环(未调用exec() )的线程中,QTimer是无法使用的.通过分析Qt源码可发现,调用QT ...

  8. 18 11 07 pygame 继续使用

    ---恢复内容开始--- 1  给原来的游戏不定时  增加一些敌机  用到了pygame的定时器    定时器就是每隔一段时间  就进行一次相同的操作 2 pyagame 在捕获键盘操作有两种 1  ...

  9. 很不错的Intent用法 适用于正在开发的伙伴。自己看到了,也分享给大家吧。

    本文介绍Android中Intent的各种常见作用. 1 Intent.ACTION_MAIN String: android.intent.action.MAIN 标识Activity为一个程序的开 ...

随机推荐

  1. java基础知识--数据类型

    计算机时识别不了我们编写的代码语言,计算机中的数据全部采用二进制表示,即0和1表示的数字,每一个0或者1就是一个位,一个位叫做一个bit(比特).(实际上计算机只能识别高低电平,而不是0和1.) 字节 ...

  2. 深入探究JVM之垃圾回收器

    @ 目录 前言 正文 一.垃圾收集算法 标记-复制 标记-清除 标记-整理 分代回收 二.常用的垃圾回收器 Serial/SerialOld ParNew Parallel Scavenge/Para ...

  3. java基础(五)--基本数据类型、占用字节、数值范围

    一.Java基本数据类型 基本数据类型有8种:byte.short.int.long.float.double.boolean.char 分为4类:整数型.浮点型.布尔型.字符型. 整数型:byte. ...

  4. linux杂七杂八

    反斜线\用于命令换行,在\之后应该直接回车换行 [root@CentOS7- ~]# cp /etc/sysconfig/network-scripts/ifcfg-ens33\ > /tmp/ ...

  5. 【laravel】Eloquent 模型事件和监听方式

    所有支持的模型事件 在 Eloquent 模型类上进行查询.插入.更新.删除操作时,会触发相应的模型事件,不管你有没有监听它们.这些事件包括: retrieved 获取到模型实例后触发 creatin ...

  6. adb常用命令大全

    1. 显示系统中全部Android平台:    android list targets2. 显示系统中全部AVD(模拟器):  启动制定模拟器:emulator -avd 模拟器名字    andr ...

  7. 11-Pandas之排序(df.sort_index()、df.sort_values()、随机重排、随机采样)

    排序是一种索引机制的一种常见的操作方法,也是Pandas重要的内置运算,主要包括以下3种方法: 排序方法 说明 sort_values() 根据某一列的值进行排序 sort_index() 根据索引进 ...

  8. PHP diskfreespace() 函数

    定义和用法 diskfreespace() 函数返回指定目录的可用空间,以字节为单位. 该函数是 disk_free_space() 函数的别名. 语法 diskfreespace(directory ...

  9. SpringBoot注解综合

    SpringBoot注解综合 @Bean 注解通常会应用在一些配置类(由@Configuration注解描述)中,用于描述具备返回值的方法,然后系统底层会通过反射调用其方法,获取对象基于作用域将对象进 ...

  10. Mac IDEA 免激活破解版 亲测有效 2020.8.1记

    开局一张图 下载地址 链接: https://pan.baidu.com/s/1OKbYCRQiZ3ip0Gzle5wydg 密码: iwfb 步骤 卸载之前的IDEA(没安装过,可忽略) 将下载后的 ...