wcscpy 不接受目标变量中的 TCHAR
wcscpy Does Not Accept TCHAR in Destination Variable
[VS10]目的是将驱动器文字串复制到*.dst中
TCHAR *driveIDBase;
...
wcscpy_s (driveIDBase, MAX_PATH-3, L"\\?\C:\*");
这会产生错误
IntelliSense: no instance of overloaded function "wcscpy_s" matches
the argument list
请注意,ANSI 版本运行良好:
strcpy_s (driveIDBase, MAX_PATH-3, "C:\*");
假设我们尝试明显的解决方法:
strcpy_s (driveIDBase, MAX_PATH-3, "\\?\C:\");
我们可以调用转换 (wchar_t *) driveIDBase 可靠吗?也就是说,WIN32_FIND_DATAW 会将字符串解释为 "C:\"?
此外,MSDN 中的这句话是什么意思?
The "\?\" prefix turns off automatic expansion of the path string,
值得注意的是 TCHAR 的 Stack Overflow 定义:
A #define for either char or wchar_t, used for porting ancient windows
applications.
正在组装的代码不是一个古老的端口,尽管将其包含在当前项目中的最初原因是建议(在较旧的线程中)用于某些 API 函数的转换。
由于 MBCS 的逐步淘汰,这些天在 Unicode 中构建项目更可取,正如 Bo 在上面所建议的那样,这使得 TCHAR 宏的使用变得多余。
至于问题的第二部分,假设创建了一个宽字符目录:
%USERPROFILE%\This Is A SubDirectory of %USERPROFILE% Not C-Colon-Backslash-Users-Backslash-MyUserName-- Being the Expanded Directory Path We Intended to Use
我们注意到在 \\?\ 下不会在 "C:\Users\MyUserName" 中创建给定的子目录。事实上,在大多数情况下它不能,因为 C:\Users 永远不会在第一个实例中使用 \\?\ 前缀创建。
用另一个问题结束这部分答案:
关于 MSDN 中同一页面的另一个声明:
The maximum path of 32,767 characters is approximate, because the
"\?\" prefix may be expanded to a longer string by the system at run
time, and this expansion applies to the total length,
运行时间的扩展不是自动的吗?
[VS10]目的是将驱动器文字串复制到*.dst中
TCHAR *driveIDBase;
...
wcscpy_s (driveIDBase, MAX_PATH-3, L"\\?\C:\*");
这会产生错误
IntelliSense: no instance of overloaded function "wcscpy_s" matches the argument list
请注意,ANSI 版本运行良好:
strcpy_s (driveIDBase, MAX_PATH-3, "C:\*");
假设我们尝试明显的解决方法:
strcpy_s (driveIDBase, MAX_PATH-3, "\\?\C:\");
我们可以调用转换 (wchar_t *) driveIDBase 可靠吗?也就是说,WIN32_FIND_DATAW 会将字符串解释为 "C:\"?
此外,MSDN 中的这句话是什么意思?
The "\?\" prefix turns off automatic expansion of the path string,
值得注意的是 TCHAR 的 Stack Overflow 定义:
A #define for either char or wchar_t, used for porting ancient windows applications.
正在组装的代码不是一个古老的端口,尽管将其包含在当前项目中的最初原因是建议(在较旧的线程中)用于某些 API 函数的转换。
由于 MBCS 的逐步淘汰,这些天在 Unicode 中构建项目更可取,正如 Bo 在上面所建议的那样,这使得 TCHAR 宏的使用变得多余。
至于问题的第二部分,假设创建了一个宽字符目录:
%USERPROFILE%\This Is A SubDirectory of %USERPROFILE% Not C-Colon-Backslash-Users-Backslash-MyUserName-- Being the Expanded Directory Path We Intended to Use
我们注意到在 \\?\ 下不会在 "C:\Users\MyUserName" 中创建给定的子目录。事实上,在大多数情况下它不能,因为 C:\Users 永远不会在第一个实例中使用 \\?\ 前缀创建。
用另一个问题结束这部分答案:
关于 MSDN 中同一页面的另一个声明:
The maximum path of 32,767 characters is approximate, because the "\?\" prefix may be expanded to a longer string by the system at run time, and this expansion applies to the total length,
运行时间的扩展不是自动的吗?