I am currently trying to make a call to this function call. Here's the declaration:
const void* WINAPI CertCreateContext(
__in开发者_JAVA百科 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++?
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:
void f( const BYTE * p ) {
// stuff
}
BYTE b = 42;
BYTE a[] = { 1, 2, 3 };
f( & b );
f( a );
You will of course need to #include the header that declares the type BYTE.
You only need to declare a BYTE*
, the compiler will automatically cast's non-const
s to const
s.
According to the documentation:
pbEncoded is a pointer to a buffer that contains the existing encoded context content to be copied.
Pass in a regular pointer to BYTE. The const
there indicates that the pointed-to object will not be modified inside the function.
精彩评论