⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 derived.bas

📁 此源码为vb圣经编码
💻 BAS
字号:
Attribute VB_Name = "modDerived"
'***************************************************************
' (c) Copyright 2000 Matthew J. Curland
'
' This file is from the CD-ROM accompanying the book:
' Advanced Visual Basic 6: Power Techniques for Everyday Programs
'   Author: Matthew Curland
'   Published by: Addison-Wesley, July 2000
'   ISBN: 0-201-70712-8
'   http://www.PowerVB.com
'***************************************************************
Option Explicit

Private Const cVTableSize As Long = 8
Private Type WrapVTable
    VTable(cVTableSize - 1) As Long
End Type
Private m_VTable As WrapVTable
Private m_pVTable As Long

Public Type BaseOverride
    BD As BlindDelegator
    Derived As Derived
End Type

Public Sub HookVTable(pBDVTable As Long)
    If m_pVTable = 0 Then
        With m_VTable
            'Duplicate the full vtable
            CopyMemory .VTable(0), ByVal pBDVTable, 4 * cVTableSize
            .VTable(7) = FuncAddr(AddressOf OverrideMe)
            m_pVTable = VarPtr(.VTable(0))
        End With
    End If
    pBDVTable = m_pVTable
End Sub
Public Function DestructBaseOverride(This As BaseOverride, pInner As IUnknown, pOuter As IUnknown) As Long
    'Clear Derived so that we don't leak
    Set This.Derived = Nothing
End Function
Private Function OverrideMe(This As BaseOverride, retVal As String) As Long
    'Make sure [out] param is NULL
    VBoost.AssignZero retVal
    
    On Error GoTo Error
    'Jump to friend function in derived class
    retVal = This.Derived.Base_OverrideMe
    Exit Function
Error:
    OverrideMe = MapError
End Function
Private Function FuncAddr(ByVal pfn As Long) As Long
    FuncAddr = pfn
End Function

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -