Search code examples
winapicomole-automation

How to create safearray of POINT?


For oleautomation type, there are VT_xxx types:

   SAFEARRAYBOUND rgsabound[1];
   rgsabound[0].lLbound = 0;
   rgsabound[0].cElements = m_cPoints;
   psa = SafeArrayCreate(VT_VARIANT, 1, rgsabound);

For custom types, there is IRecordInfo:

SafeArrayCreateEx(VT_RECORD, 1, &rgbounds, pRecInfo);

But what is the right type for windows' system type such as POINT?


Solution

  • POINT is not an OLE-compatible type. VT_RECORD only works for custom types that are defined in a TypeLibrary. You will have to either:

    1. create a TypeLibrary that replicates POINT and then retrieve IRecordInfo from the TypeLibrary

    2. create a safearray of bytes (VT_UI1) instead and then copy the raw POINT bytes into it. The receiver will then have to read the bytes according.