How to pass Structures/Types as parameters in COM DLL function?
-
Hi all, Does aNy body know how we can pass strucutres ( types in VB ) as parameters of function defined in COM DLL interface ? For e.g. I have one interface called IDatabase and i want to add method like "HRESULT SetData([in]USER userData)". In this case the DLL is compiled successfully, but when it is used in the Visual Basic, it gives error "user defined object can not be passed by value". The DLL should be used in both VB and VC++ client applicaitons. Karnav Zaveri
-
Hi all, Does aNy body know how we can pass strucutres ( types in VB ) as parameters of function defined in COM DLL interface ? For e.g. I have one interface called IDatabase and i want to add method like "HRESULT SetData([in]USER userData)". In this case the DLL is compiled successfully, but when it is used in the Visual Basic, it gives error "user defined object can not be passed by value". The DLL should be used in both VB and VC++ client applicaitons. Karnav Zaveri
It's not a simple task to pass structures in COM/DCOM. 1. A structure must be of the type VT_RECORD. 2. All the structure's fields must be of an automation-compatible type. 3. The structure must be described in a TLB. 4. The structure must have a GUID (assigned in the IDL file). 5. A special structure-oriented interface IRecordInfo must be used to manipulate structures (IRecordInfo::RecordCreate(), IRecordInfo::RecordDestroy(), etc.).