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


相关推荐

  • 【转】Asp.NetMve移除HTTP Header中服務器信息Server、X-AspNet-Version、X-AspNetMvc-Version、X-Powered-By:ASP.NET…

    【转】Asp.NetMve移除HTTP Header中服務器信息Server、X-AspNet-Version、X-AspNetMvc-Version、X-Powered-By:ASP.NET…默認情況下Chrome中截獲的HTTPHeader信息:Cache-Control:private,s-maxage=0Content-Encoding:gzipContent-Length:1184Content-Type:text/html;charset=utf-8Date:Sun,08Oct201705:01:37GMTServer:Micros…

    2022年9月29日
    0
  • fseek函数用法_fwrite函数的用法

    fseek函数用法_fwrite函数的用法转载请注明出处:https://blog.csdn.net/wl_soft50/article/details/7787521每天进步一点点–>函数fseek()用法在阅读代码时,遇到了很早之前用过的fseek(),很久没有用了,有点陌生,写出来以便下次查阅。函数功能是把文件指针指向文件的开头,需要包含头文件stdio.hfseek函数名:fseek功能:重定位流上的文件…

    2022年10月21日
    0
  • fizz buzz 翻译_thefizzbuzz中文翻译

    fizz buzz 翻译_thefizzbuzz中文翻译存档日期:2019年5月15日|首次发布:2010年10月26日GoogleBuzz允许用户将实时状态更新,新闻和内容发布到他们的Google帐户,并订阅其他人的类似更新。网络应用程序开发人员可以通过GoogleBuzzRESTAPI访问和搜索此内容。本文介绍了GoogleBuzzAPI,并在PHP应用程序上下文中对其进行了演示,并说明了如何在GoogleBuzz上…

    2022年10月15日
    0
  • java堆栈详解

    java堆栈详解java虚拟机栈栈是线程私有,他的生命周期和线程的相同。用于存储局部变量,操作数栈,动态链接,方法出口等。他会抛出两种异常,stackoverflowerror异常和outofmemoryerror异常。java虚拟机堆堆是线程共有的一块内存区域,在虚拟机启动时创建,为了存放对象实例。java堆是垃圾收集器管理的主要区域,因此很多时候被称为“GC堆”。java堆可以处于物理上不连续的内

    2022年7月8日
    20
  • 论文投稿Cover letter[通俗易懂]

    论文投稿Cover letter[通俗易懂]转自:http://blog.sciencenet.cn/blog-479412-686426.html,感谢分享!1.第一次投稿Coverletter:主要任务是介绍文章主要创新以及声明没有一稿多投DearEditors:Wewouldliketosubmittheenclosedmanuscriptentitled“PaperTitle”,whichwewis…

    2022年5月3日
    45
  • MySQL模糊查询用法大全(正则、通配符、内置函数等)[通俗易懂]

    MySQL模糊查询用法大全(正则、通配符、内置函数等)[通俗易懂]在日常使用MySQL进行模糊匹配时,我们通常用通配符%来进行匹配,其实,这只是MySQL模糊匹配的冰山一角,在MySQL中,支持模糊匹配的方法有很多,且各有各的优点。好了,今天让我带大家一起掀起MySQL的小裙子,看一看模糊查询下面还藏着多少鲜为人知的好东西。

    2022年5月7日
    300

发表回复

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

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