VarPtr in .NET

Un piccolo tip per emulare la VarPtr di VB6 in .net in modo di facilitare la conversione delle applicazioni VB6.

Public Function VarPtr(ByVal o As Object) As Integer

Dim GC As System.Runtime.InteropServices.GCHandle = System.Runtime.InteropServices.GCHandle.Alloc(o, System.Runtime.InteropServices.GCHandleType.Pinned)

Dim ret As Integer = GC.AddrOfPinnedObject.ToInt32

GC.Free()

Return ret

End Function

Print | posted on martedì 7 marzo 2006 17.26

Comments on this post

# re: VarPtr in .NET

Requesting Gravatar...
Thanks sooo much...

I tried this and it did take the errors off, i still have a lot of errors :( and so i dont know if it will work when i compile it or not. ( i'm converting a vb6 project to vb.net)

Thanks once again. :)
Left by John on giu 18, 2007 7.12

Your comment:

 (will show your gravatar)
 
Please add 2 and 3 and type the answer here: