VB6 has three cases of declaring string parameters - ByVal param As String , ByRef param As String and Function() As String . The first in the IDL corresponds to [in] BSTR param , the second to [in, out] BSTR *param , the third to [out, retval] BSTR *retval .
VB6 cannot declare [in] BSTR * , not [out] BSTR * params, but it can still use them, that is, it can call methods (in VC), which has parameters declared as out-only or in any other supported IDL way.
Also note that BSTR itself is a typedef'd pointer, something like wchar_t * , so BSTR * is actually wchar ** . The IDL needs a pointer for parameters, so you cannot declare [out] int param and [out] BSTR param also weird.
After [in] BSTR * confusion is clear (for the meaningless dual indirectness required for parameters, but not for input), the simple rule is that after you have * in the parameter declaration, the caller must release it after calling the method, if it is no longer NULL.
[in, out] SAFEARRAY(BSTR)* pArray displayed in ByRef pArray() As String in VB6, and you cannot change it to ByVal , that is * VB6 is required, so it cannot be in only one, and the caller must free safe array. This is not a safe array. Only
source share