dotnet-Snippets.com
Snippets: 61 | Registered User: 61 | Visitors online: 12
Main Menu

Home
Random Snippet
FAQs
Contact Us
Imprint
RSS Feeds

Rss All languages
Rss C#
Rss VB.NET
Rss C++
Rss J#
Rss ASP.NET
Google Ads

Sri Lanka .NET 
                Forum Member
VarPtr for .NET

Author: Tim Hartwig
Programming Language: VB.NET Rating:
not yet rated

Views: 8687

Description:

The VarPtr function will return an offset where a given object is located in the memory.

In VB6 this function already exists but not in VB.NET, so I build a .NET Version of the VarPtr function.




Visual Basic
1
2
3
4
5
6
7
Public Function VarPtr(ByVal e As Object) As Integer
    Dim GC As GCHandle = GCHandle.Alloc(e, GCHandleType.Pinned)
    Dim GC2 As Integer = GC.AddrOfPinnedObject.ToInt32
    GC.Free()
    Return GC2
End Function


This Snippets could be interesting for you:
No results available

Poor Excellent
1 2 3 4 5 6 7 8 9 10
Sign in to vote for this snippet.

Comments:
(Please log in to wrtite an comment.)