RtlStringCbPrintf is not in ntstrsafe.h as described

RtlStringCbPrintf is not in ntstrsafe.h as described

本文关键字:as described ntstrsafe in is not RtlStringCbPrintf      更新时间:2023-10-16

我试图使用RtlStringCbPrintf与Winsock内核。我已经包含了nstrsafe .h,但是编译器给了我错误

Error 4 error C3861: 'RtlStringCbPrintf': identifier not found  c:bwepic_slmusslcommmusslcommcommmessengersocketx.h   124 1   CommMessenger

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

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

使用RtlStringCbPrintfW处理Unicode字符串和RtlStringCbPrintfA处理ANSI字符串。您使用的形式取决于你的数据. .

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

你可以自己定义RtlStringCbPrintf():

#if defined(UNICODE)
# define RtlStringCbPrintf RtlStringCbPrintfA
#else
# define RtlStringCbPrintf RtlStringCbPrintfW
#endif
相关文章: