0

I want to pass a SafeArray to a function in C++ COM.

I have an object of MetadataListEntity class that I have initialized

IMetadataListEntityPtr metadataListEntity = NULL;
hr = CoCreateInstance(
    __uuidof(MetadataListEntity),
    NULL, 
    CLSCTX_INPROC_SERVER,
    __uuidof(IMetadataListEntityPtr),
    (void**)&metadataListEntity);

metadataListEntity->PutBaseType(0);
metadataListEntity->PutDescription("");
metadataListEntity->PutId("78ba31f9-11ed-4669-9143-c4ac9f11b28b");
metadataListEntity->PutIsChecked(true);
metadataListEntity->PutItemCount(24);
metadataListEntity->PutTitle("AgeMaster");

I want to create an array of MetadataListEntity objects and pass it to a function that accepts a SafeArray.

Ho do I do that ?

Thanks, Gagan

Captain Obvlious
  • 19,754
  • 5
  • 44
  • 74
Gags
  • 827
  • 2
  • 13
  • 29
  • 1
    Which part of [the documentation](http://msdn.microsoft.com/en-us/library/cc237826.aspx) don't you understand? – Oswald Aug 02 '13 at 04:44
  • 1
    It's important to know what kind of safearray the function you plan to call expects. It could be a safearray of `IUnknown*` pointers (in which case you pass `VT_UNKNOWN` to `SafeArrayCreate`), or of `IDispatch*`pointers (`VT_DISPATCH`), or of `VARIANT`s (`VT_VARIANT`) each of which, in turn, would wrap an `IUnknown*` or `IDispatch*`. The documentation for the function should tell you which way to go. – Igor Tandetnik Aug 02 '13 at 04:46
  • ^Or failing that, the IDL. – Medinoc Aug 05 '13 at 11:31

0 Answers0