Saturday, March 6, 2010

GetRecordInfoFromTypeInfo and GetRecordInfoFromGuids returns E_INVALIDARG if COM structure contains a GUID member field

Recently I was working on developing a COM service which returns a SAFERRAY of structure as out parameter. This structure has member of type GUID.

To create SAFEARRAY of custom data types, you need to get the IRecordInfo pointer to the structure and pass it to SafeArrayCreateEx. You can get IRecordInfo pointer to the custom structure by calling either GetRecordInfoFromTypeInfo or GetRecordInfoFromGuids API.

Both of these API returns E_INVALIDARG if the sturcture contains member of type GUID. One way to workaround this problem is to convert GUID as BSTR.

This is a defect in Microsoft Visual Studio 2008 and hopefully will get fixed in next versions. Link to the microsoft page for same. https://connect.microsoft.com/VisualStudio/feedback/details/380266/getrecordinfofromtypeinfo-returns-e-invalidarg-if-a-com-structure-contains-a-guid-field

No comments: