Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- HRESULT GetList([in,out] SAFEARRAY(struct MyStruct)* myStructs);
- // I have also tried with [out] instead of [in, out]
- [uuid(628913FC-CC26-1654-472F-0B70CC39DEE0)]
- struct MyStruct
- {
- int myInt;
- DOUBLE myDouble;
- };
- STDMETHODIMP MyClass::GetList(SAFEARRAY** myStructs)
- {
- SAFEARRAY* psa = *myStructs;
- SAFEARRAYBOUND sab = {someSize, 0};
- MyStruct *pData;
- IRecordInfo *pRI;
- HRESULT hr;
- hr = GetRecordInfoFromGuids(LIBID_MyCOMLib, 1, 0, 0x409, __uuidof(MyStruct), &pRI);
- psa = SafeArrayCreateEx(VT_RECORD, 1, &sab, pRI);
- pRI->Release();
- pRI = NULL;
- hr = SafeArrayAccessData(psa, (void**)&pData);
- for (size_t i = 0; i < someSize; i++)
- {
- pData[i].myInt = someInt;
- pData[i].myDouble = somedouble;
- }
- hr = SafeArrayUnaccessData(psa);
- return S_OK;
- }
- Option Strict
- ...
- <MarshalAs(UnmanagedType.SafeArray, safearraysubtype:=VarEnum.VT_RECORD)>
- Private m_List As MyStruct()
- Private Sub btnGetList_Click(sender As System.Object, e As System.EventArgs)
- Dim m_List() As MyStruct
- m_ComObject.GetList(m_List)
- ' I have tried several other things, getting different errors with each of them'
- 'm_ComObject.GetList(CType(m_List, Array))'
- 'Dim structs() As MyStruct'
- 'Dim arr as System.Array = structs '
- 'm_ComObject.GetList(arr)'
- For Each o In cortes
- Dim s As MyStruct = CType(o, MyStruct)
- MsgBox(s.myInt)
- Exit For
- Next
- End Sub
- Dim m_List() As SceneCutInfo
- m_ComObject.GetList(m_List)
- Dim m_List() As MyStruct
- m_ComObject.GetList(m_List)
Add Comment
Please, Sign In to add comment