-
Pointers?
In vb6.0 I was able to use VarPtr to get memory address's. Now in VB.Net VarPtr, ObjPtr, ect. are now removed. Why they did this I have no clue. Anyways. What would the equivelent be? Microsoft said to use:
[Highlight=VB]
Dim MyGCHandle As GCHandle = GCHandle.Alloc(MyObj, GCHandleType.Pinned)
Dim Address As IntPtr = MyGCHandle.AddrOfPinnedObject()
'Here is part of my code I'm trying to get working.
'declarations section
Private Structure WaveInCaps
Dim ManufacturerID As Short 'wMid
Dim ProductID As Short 'wPid
Dim DriverVersion As Integer 'MMVERSIONS vDriverVersion
<VBFixedArray(32)> Dim ProductName_Renamed() As Byte 'szPname[MAXPNAMELEN]
Dim Formats As Integer
Dim Channels As Short
Dim Reserved As Short
End Structure
'have in a button
Dim Caps as WaveInCaps
Dim MyGCHandle As GCHandle = GCHandle.Alloc(Caps, GCHandleType.Pinned)
Dim Address As IntPtr = MyGCHandle.AddrOfPinnedObject()
' Allow the object to be moved again.
MyGCHandle.Free()
When I run the code I get a error:
An unhandled exception of type 'System.ArgumentException' occurred in mscorlib.dll
Additional information: Object contains non-primitive or non-blittable data.
It is highlighting:
MyGCHandle As GCHandle = GCHandle.Alloc(Caps, GCHandleType.Pinned)
So whats going on? Anyone know how to fix it. I really need the address to the structure. Thanks for any help.