VB6对象与地址相互转换

Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" _
            (lpDest As Any, lpSource As Any, ByVal nCount As Long)

Private Sub Form_Load()
    Dim c As New clsTest
    c.Name = "Hello,World!"
    
    Dim addr As Long
    addr = ObjPtr(c)
    
    Dim c2 As clsTest
    CopyMemory c2, addr, 4

    MsgBox c2.Name
    c2.Name = "haha"

    CopyMemory c2, 0&, 4
End Sub

 

posted on 2014-12-30 11:20  空明流光  阅读(402)  评论(0编辑  收藏  举报

导航