If tLib <> 0 Then
tadd = GetProcAddress(tLib, "DllGetClassObject")
End If
Dim asmadd&
If tadd <> 0 Then
'获取vtable地址
CopyMemory vTab, ByVal ObjPtr(tobj), 4
asmadd = VarPtr(asm)
'替换掉cFucPtr.DllGetClassObject地址
CopyMemory ByVal (vTab + (8 - 1) * 4), asmadd, 4
'设置函数地址
tobj.SetFunctionPtr tadd
tobj.DllGetClassObject ClsId_Obj, iid_iclassfactory, tFac
If Not tFac Is Nothing Then
tFac.CreateInstance Nothing, iid_iunknow, tUn
Set tFac = Nothing
Set tDem = tUn
Set tUn = Nothing
tDem.test
End If
End If
Set tDem = Nothing
If tLib <> 0 Then FreeLibrary tLib
'一定要在所有对象都释放掉了才能使用FreeLibrary,不然会出错
将上面的代码修改一下,就可以很方便的在vb中使用函数指针了,hoho,vb可以用函数指针咯,不写了.
| 对此文章发表了评论 |

