I tried passing an std::string via RPC, but I got the following error:
MIDL2025: syntax error: expecting a type specification or a storage specifer or a type qualifier near 开发者_开发知识库"string"
Extract from code:
interface TestInterface
{
unsigned int HelloUser([in] const string user);
}
Is this possible?
You must use a BSTR
. Also, no const
. By specifying the argument as [in]
, it is already understood that the callee will not modify the string, and even if it did modify, it won't be marshaled back to the caller.
The _bstr_t
class will help with conversion. Note that BSTR
is always based on WCHAR
, which is 16-bit. Thus, use std::wstring
.
精彩评论