VB.Net to COM marshalling

  • Thread starter Thread starter Hemal
  • Start date Start date
H

Hemal

I am using a COM interface decalared as follows from VB.Net

interface ISample : IDispatch
{
[id(1), HRESULT Write(long* pBuffer)
}

In VB.Net, I get the address from the call below and pass it to the
"Write"
function which is declared as

Write( ByRef pBuffer as Integer )

.....
Dim ptrBuffer As Integer =
playbackArrayHandle.AddrOfPinnedObject.ToInt32
obj.Write( ptrBuffer )

However, the COM object receives the pointer as a long** or a
pointer-to-pointer-to a long. I understand that if the type was
changed to ByVal this will work. But I cannot change the interface and
I need a pointer to the long. How can I fix this?

Thanks
Hemal
 
Hi,

Why dont you use an inptr instead of integer.

http://msdn.microsoft.com/library/d...us/cpref/html/frlrfsystemintptrclasstopic.asp


Ken
------------------
I am using a COM interface decalared as follows from VB.Net

interface ISample : IDispatch
{
[id(1), HRESULT Write(long* pBuffer)
}

In VB.Net, I get the address from the call below and pass it to the
"Write"
function which is declared as

Write( ByRef pBuffer as Integer )

.....
Dim ptrBuffer As Integer =
playbackArrayHandle.AddrOfPinnedObject.ToInt32
obj.Write( ptrBuffer )

However, the COM object receives the pointer as a long** or a
pointer-to-pointer-to a long. I understand that if the type was
changed to ByVal this will work. But I cannot change the interface and
I need a pointer to the long. How can I fix this?

Thanks
Hemal
 
Back
Top