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, noconst. 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_tclass will help with conversion. Note thatBSTRis always based onWCHAR, which is 16-bit. Thus, usestd::wstring.