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


相关推荐

  • MyBatis常用对象SqlSessionFactory和SqlSession介绍和运用

    MyBatis常用对象SqlSessionFactory和SqlSession介绍和运用前言:学习框架一个比较好的路径阅读源码.本文介绍的SqlSessionFactory和SqlSession.可以通过了解SqlSessionFactory接口和SqlSession接口以及两个的实现类入手,去看源码了解实现过程.最好能把项目下载到本地,慢慢分析实现过程.Myabtis官网:http://www.mybatis.org/github地址:https://github.com/myb

    2022年4月28日
  • linux——挖矿程序处理

    linux——挖矿程序处理记一次挖矿程序入侵以及解决实操!1,过程记录系统被挖矿程序入侵,导致系统CPU飙升。kill掉进程后自动重启。无论kill-9还是直接把系统中nanoWatch所对应的进程文件删除,一样会定时重启。使用crontab-e查看当前系统的定时任务信息,如下:显示定时从链接中下载文件,于是在浏览器中访问该地址,下载的文件截图如下:很明显,这是一个恶意脚本,定时检查…

    2022年6月16日
  • vc++连接sql数据库_vscode怎么连接数据库

    vc++连接sql数据库_vscode怎么连接数据库vc连接mysql数据库的方法:首先打开VC6;然后在中间列表框中添加本地安装MySQL的include目录路径;接着选中“Libraryfiles”并添加MySQL的Lib目录路径;最后进行编程测试即可。一、MySQL的安装Mysql的安装去官网下载就可以。。。最新的是5.7版本。。二、VC6.0的设置(1)打开VC6.中选0工具栏Tools菜单下的Options选项,在Directorie…

    2022年8月12日
  • python 请在微信客户端打开_如何实现‘请在微信客户端打开链接’

    python 请在微信客户端打开_如何实现‘请在微信客户端打开链接’想要实现请在微信客户端打开链接在代码中加入以下代码即可varua=navigator.userAgent.toLowerCase();varisWeixin=ua.indexOf(‘micromessenger’)!=-1;varisAndroid=ua.indexOf(‘android’)!=-1;varisIos=(ua.indexOf(‘iphone’)!=…

    2022年6月7日
  • 5G Wifi频段及信道介绍[通俗易懂]

    5G Wifi频段及信道介绍[通俗易懂]5GWifi频段及信道介绍WiFi三频AP规划信道时,建议分别采用2.4G、5.2G、5.8G频段可用信道。2.4G频段;5.2G频段;5.8G频段。中国5GWiFi频段5.8GHz频段,中国开放只有149、153、157、161、165这5个信道;其中可支持一组80MHz信道捆绑(149-161)或两组40MHz捆绑(149-153和157-161);所以165信道支持…

    2022年6月7日
  • 简单说明什么是宏观社会环境和微观社会环境?_kafka是什么

    简单说明什么是宏观社会环境和微观社会环境?_kafka是什么Kafka通俗理解Apachekafka是消息中间件的一种,我发现很多人不知道消息中间件是什么,在开始学习之前,我这边就先简单的解释一下什么是消息中间件,只是粗略的讲解,目前kafka已经可以做更多的事情。举个例子,生产者消费者,生产者生产鸡蛋,消费者消费鸡蛋,生产者生产一个鸡蛋,消费者就消费一个鸡蛋,假设消费者消费鸡蛋的时候噎住了(系统宕机了),生产者还在生产鸡蛋,那新生产的鸡蛋就丢失了。…

    2022年10月7日

发表回复

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

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