----------------------------------------------------------------------------
----
Private Declare Sub ICopyMemory Lib "kernel32" Alias "RtlMoveMemory" _
(Destination As Any, Source As Any, ByVal Length As Long)
Public Function RefCount(ByVal unk As IUnknown) As Long
Dim RefCountAddr As Long
Dim RefCounter As Long
RefCountAddr = ObjPtr(unk) + 4
If RefCountAddr = 4 Then
RefCount = 0
Exit Function
End If
ICopyMemory RefCounter, ByVal RefCountAddr, 4
RefCount = RefCounter - 2
End Function
Public Sub AddRef(ByVal unk As IUnknown)
Dim RefCountAddr As Long
Dim RefCounter As Long
RefCountAddr = ObjPtr(unk) + 4
If RefCountAddr = 4 Then
RefCount = 0
Exit Function
End If
ICopyMemory RefCounter, ByVal RefCountAddr, 4
RefCounter = RefCounter + 1
ICopyMemory ByVal RefCountAddr, RefCounter, 4
End Sub
Public Sub Release(ByVal unk As IUnknown)
Dim RefCountAddr As Long
Dim RefCounter As Long
RefCountAddr = ObjPtr(unk) + 4
If RefCountAddr = 4 Then
RefCount = 0
Exit Function
End If
ICopyMemory RefCounter, ByVal RefCountAddr, 4
RefCounter = RefCounter - 1
ICopyMemory ByVal RefCountAddr, RefCounter, 4
End Sub
----------------------------------------------------------------------------
----------------------------
I know this works for VB Classes, and it *should* work for controls as well,
though I never tested it.
If you are intersted in doing some nasty things with VB then go and read:
>> Dan Appleman's developing COM Components with Visual Basic 6.0: A Guide
to the perplexed<<
Hope this helps
Alexander Milenz
"Phil Jollans" <Phil.J...@messring.de> schrieb im Newsbeitrag
news:90gb8m$pd2$1...@ninja.muc.baycix.de...
"Alexander Milenz" <Ras...@bigfoot.com> wrote in message
news:eN1aQzj...@cppssbbsa02.microsoft.com...
> If you are intersted in doing some nasty things with VB then go and read:
> >> Dan Appleman's developing COM Components with Visual Basic 6.0: A Guide
> to the perplexed<<
I know that Appleman explains the technique quite well in his book, so all I
can suggest
is: go and read that book - it's worth it.
Alex
"Leo" <nk...@263.net> schrieb im Newsbeitrag
news:#1WscimXAHA.307@cppssbbsa05...