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


相关推荐

  • 开源 网管 工具_网管软件

    开源 网管 工具_网管软件Nagios:最大的亮点是轻量灵活,且报警机制很强,如果你只是需要监控服务器/服务是否在运行,Nagios以前只是从目标主机收集信息,,并且有很强大的发送报警信息的功能。适合监视大量服务器上面的大批服务是否正常,重点并不在图形化的监控,其集成的很多功能例如报警,都是cacti没有或者很弱的.cacti主要用途还是用来收集历史数据和画图,所以界面比nagios漂亮很多cact

    2022年9月26日
    1
  • 医疗器械进销存软件管理系统_简单仓库管理系统

    医疗器械进销存软件管理系统_简单仓库管理系统开发环境:Eclipse/MyEclipse、Tomcat8、Jdk1.8数据库:MySQL适用于:课程设计,毕业设计,学习等等系统介绍有偿

    2025年9月2日
    7
  • 计算机基础复习题库

    计算机基础复习题库写在最前面,本文中题库为搜寻整理所得。一、单选题练习1.完整的计算机系统由( C )组成。A.运算器、控制器、存储器、输入设备和输出设备B.主机和外部设备C.硬件系统和软件系统D.主机箱、显示器、键盘、鼠标、打印机2.以下软件中,( D )不是操作系统软件。A.WindowsxpB.unixC.linux  D.microsoftoffice3.用一个字节最多能编出(D)不同的码。A.8个…

    2022年4月15日
    57
  • PyQt5(designer)入门教程

    PyQt5(designer)入门教程PyQt5入门教程注:这是当时闲着无聊写到githubpage的,在CSDN上也看了大佬们各种各样的教程跟疑难杂症解答,感觉我这个不放出来也有点可惜,希望各位能够从中收益吧。在网上看了不少关于PyQt5的中文教程,但是无外乎是过时了,讲解不清晰易懂,或者资料不完整。Youtube上面倒是有不少视频,但是不少Youtuber居然还在手写ui而不是利用方便快捷的QtDesigner。仅有的几个…

    2022年9月14日
    2
  • CentOS下Apache配置虚拟主机[通俗易懂]

    CentOS下Apache配置虚拟主机[通俗易懂]有时候我们往往一个服务器会运行多个应用,此时就需要给每个应用创建虚拟主机了,这里我创建三个文件夹,分别运行三个页面:

    2022年9月15日
    2
  • WEB日志格式

    WEB日志格式WEB日志格式日志格式类型:常见日志格式:参考:WEB日志格式CustomLogFormats:普通日志格式日志格式类型:目前常见的WEB日志格式主要由两类Apache的NCSA日志格式,NCSA格式分为NCSA普通日志格式(CLF)NCSA扩展日志格式(ECLF)IIS的W3C日志格式目前最常用的是NCSA扩展日志格式(ECLF…

    2022年6月10日
    32

发表回复

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

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