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


相关推荐

  • 怎么新建pytest的ini文件_python读取配置文件

    怎么新建pytest的ini文件_python读取配置文件前言pytest配置文件可以改变pytest的运行方式,它是一个固定的文件pytest.ini文件,读取配置信息,按指定的方式去运行查看pytest.ini的配置选项pytest-h找到以下

    2022年7月28日
    24
  • java的三种工厂模式「建议收藏」

    java的三种工厂模式「建议收藏」一,简单的工厂模式首先举一个例子:我们现在开了一家饭馆:然后呢我们的大厨可以做三种菜,还有一句潇洒的抱怨:   下面客人进场,开始点餐:我们观察上面的代码,虽然很好的完成了任务,但是,我们的三个实现类和和借口紧密的绑定到了一起,这意味着我们的代码耦合出现严重问题,不利于以后的维护,试想顾客点餐需要与后厨大厨直接接触,这肯定是一个不好的体验,那…

    2022年7月7日
    23
  • 基于大数据的舆情分析系统架构(架构篇)

    前言互联网的飞速发展促进了很多新媒体的发展,不论是知名的大V,明星还是围观群众都可以通过手机在微博,朋友圈或者点评网站上发表状态,分享自己的所见所想,使得“人人都有了麦…

    2022年4月5日
    218
  • python一维数组转置_python矩阵转置[通俗易懂]

    python一维数组转置_python矩阵转置[通俗易懂]python中的矩阵转置首先,数据应该是np.asarray型,然后,使用numpy.transpose来操作。transpose方法只能处理高维数组(>1),如果处理一维数组会报错;对于二维数组:data1=np.arange(4).reshape((2,2))print(data1)>>[[01][23]]data1=np.transpose(data1)print(data1)>…

    2022年5月5日
    212
  • IE7,8,9兼容性处理

    IE7,8,9兼容性处理

    2022年1月1日
    44
  • Java工程师自我评价(软件工程师自我评价)

    JAVA工程师简历自我评价无论在学习、工作或是生活中,我们都可能会使用到自我评价,自我评价具有重要的社会功能,它极大地影响人与人之间的交往方式。那要怎么写好自我评价呢?以下是小编收集整理的JAVA工程师简历自我评价,仅供参考,希望能够帮助到大家。JAVA工程师简历自我评价11、有较强的分析、解决问题的能力,具有较强逻辑思维能力和表达能力。2、性格开朗,积极乐观,能以极大的’热情投入工作。3、具…

    2022年4月15日
    48

发表回复

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

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