Sometime back I was wondering about whether there was a way to transfer our good ol’ NULL terminated strings using COM apart from using BSTR’s.
That’s how I bumped into “string” attribute provided by MIDL.
Here is how we use it…
typedef [string] char NormalString;
[id(1), helpstring( "Displays null terminated UNICODE strings" )]
HRESULT ShowMsgUnicodeString( [in,string] wchar_t* wCharString_i );
[id(2), helpstring( "Displays null terminated ANSI strings" )]
HRESULT ShowMsgAnsiString( [in,string] char* cString_i );
Well if we don’t specify “string” then MIDL treats the parameter as an address of a wchar/char.
Callers can invoke the call as they would normally do with a function.