在 c++ 中声明 const BYTE *
我目前正在尝试拨打 此 函数调用。这是声明:
const void* WINAPI CertCreateContext(
__in DWORD dwContextType,
__in DWORD dwEncodingType,
__in const BYTE *pbEncoded,
__in DWORD cbEncoded,
__in DWORD dwFlags,
__in_opt PCERT_CREATE_CONTEXT_PARA pCreatePara
);
如您所见,第三个输入参数调用 const BYTE * ,它表示您尝试创建的编码证书。如何在c++中定义这样的变量?
I am currently trying to make a call to this function call. Here's the declaration:
const void* WINAPI CertCreateContext(
__in DWORD dwContextType,
__in DWORD dwEncodingType,
__in const BYTE *pbEncoded,
__in DWORD cbEncoded,
__in DWORD dwFlags,
__in_opt PCERT_CREATE_CONTEXT_PARA pCreatePara
);
As you can see, the third input param calls for a const BYTE * which represents the encoded certificate you are trying to create. How do I define such a variable in c++?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
你不需要。函数参数是一个指向const BYTE的指针,这意味着函数不会改变它指向的字节。一个简单的例子:
您当然需要 #include 声明 BYTE 类型的标头。
You don't need to. The function parameter is a pointer to a const BYTE, which means the function will not change the byte it points to. A simple example:
You will of course need to #include the header that declares the type BYTE.
您只需要声明一个
BYTE*
,编译器就会自动将非const
转换为const
。You only need to declare a
BYTE*
, the compiler will automatically cast's non-const
s toconst
s.根据文档:
pbEncoded 是一个指向缓冲区的指针,该缓冲区包含要复制的现有编码上下文内容。
According to the documentation:
pbEncoded is a pointer to a buffer that contains the existing encoded context content to be copied.
传入一个指向 BYTE 的常规指针。其中的
const
表示所指向的对象不会在函数内部被修改。Pass in a regular pointer to BYTE. The
const
there indicates that the pointed-to object will not be modified inside the function.