ObjPtr 和 ObjectFromPtr
(创建时间:2012年08月14日 02:03:00)
Jangogo :
VB
- Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (dest As Any, Src As Any, ByVal l As Long)
- Public Function ObjectFromPtr(ByVal lPtr As Long) As Object
- Dim objT As Object
- If Not (lPtr = 0) Then
- ' Author: Bruce McKinney
- ' Turn the pointer into an illegal, uncounted interface
- CopyMemory objT, lPtr, 4
- ' Do NOT hit the End button here! You will crash!
- ' Assign to legal reference
- Set ObjectFromPtr = objT
- ' Still do NOT hit the End button here! You will still crash!
- ' Destroy the illegal reference
- CopyMemory objT, 0&, 4
- ' End Author Bruce McKinney
- End If
- End Function
- ''ObjPtr VB自带
文档中心