sekhar.roy
9/5/2007 3:38:00 PM
Hi,
I'm trying to access a struct pointer from a ATL COM DLL.
The Signature of the function in C++ end is like -
C++:
STDMETHODIMP Ctest::GetPtr(DataRecord** pstData)
I have added the DLL as a referance in the project and trying to
access from C# like that -
IntPtr ds = Marshal.AllocHGlobal(4);
UnManagedLib.DataRecord dtDLL;
testClass cls = new testClass();
cls.GetPtr(ds);
dtDLL=
(UnManagedLib.DataRecord)Marshal.PtrToStructure(ds,typeof(UnManagedLib.DataRecord));
I have marshal the whole structure in C# end. My Question is what is
the best way to Set/Get data from a unmanaged nested structure ? Is it
safe to using unsafe block ? The above code is not returning proper
values.
If you have any sample code I would appreciate that.
--Sekhar
sekhar_k_roy@yahoo.com