c++ - 如前所述,RtlStringCbPrintf 不在 ntstrsafe.h 中

标签 c++ string unicode-string windows-kernel strsafe

我正在尝试将 RtlStringCbPrintf 与 Winsock 内核一起使用。我包含了 Ntstrsafe.h 但编译器给我错误

Error 4 error C3861: 'RtlStringCbPrintf': identifier not found  c:\bw\epic_sl\musslcomm\musslcomm\commmessenger\socketx.h   124 1   CommMessenger

如果我使用 RtlStringCbPrintfARtlStringCbPrintfW 那么它会编译。为什么我不能使用通用版本?在 Ntstrsafe.h 中,我看到了 RtlStringCbPrintfARtlStringCbPrintfW 的原型(prototype)声明,但没有 RtlStringCbPrintf 的声明,尽管注释引用了它。为什么我不能使用通用形式以便我的字符集属性选择要使用的版本?我的字符集属性设置为使用多字节字符集

最佳答案

因为windows没有为这两个函数提供RtlStringCbPrintf定义。来自 msdn:

Use RtlStringCbPrintfW to handle Unicode strings and RtlStringCbPrintfA to handle ANSI strings. The form you use depends on your data..

msdn 中的示例使用 RtlStringCbPrintfW() 函数,而不是 RtlStringCbPrintf()。

你可以自己定义 RtlStringCbPrintf():

#if defined(UNICODE)
# define RtlStringCbPrintf RtlStringCbPrintfA
#else
# define RtlStringCbPrintf RtlStringCbPrintfW
#endif

关于c++ - 如前所述,RtlStringCbPrintf 不在 ntstrsafe.h 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25043348/

相关文章:

python - 如何在这里找到最长的字符串?

c++ - 制作一个包装器 dll 让 gamemaker 处理 C++ 标准库

c++ - 判断模板参数包中 "optimal"公共(public)数值类型

c++ - cout 给出运行时错误

java - 使用哪一个 - String 或 StringBuffer 连接

PHP - 包含表情符号/特殊字符的字符串长度

c++ - C++返回默认值NullObjectPattern

linux - 从目录中的所有文件中删除包含字符串的行

c# - 在 C# 中显示 unicode 文本

python - 如何计算字符串中的字母?