分享

VFB_调用DLL

 nxhujiee 2020-07-09
'--------------------------------------------------------------------------------
Sub Form1_Command1_BN_Clicked(hWndForm As hWnd, hWndControl As hWnd '单击
    
text1.text Str(Add2(370037607, Rnd 100))
    
AfxMsg testdll("ddddd")
End Sub
'--------------------------------------------------------------------------------
Sub Form1_Command2_BN_Clicked(hWndForm As hWnd, hWndControl As hWnd '单击
    
Dim As Any Ptr library DyLibLoad"dlltest'就文件名,不能带 .DLL
    
If (library 0Then
        
AfxMsg "加载DLL失败"
        Return
    End If
    Dim 
AddNumbers As Function(ByVal As Integer, ByVal As Integer) As Integer
    
AddNumbers DyLibSymbol(library, "ADD2" 特别提醒,必须全部大写
    '从DLL查看器里可以看到全称是 ADD2@8 ,而FB用FB的DLL可以省略  @8 的符号
    
If (AddNumbers 0Then
        
AfxMsg "无法从开发DLL例题库中检索Add2()函数的地址"
        Return
    End If
    
text2.text Str(AddNumbers(100, Rnd 100))
    
AfxMsg "使用完成"
    DyLibFree(library '卸载DLL ,特别注意,假如DLL还在工作,卸载会让软件崩溃
    '本例题里,加载会弹窗提示,就是在工作,必须先关弹窗在卸载
    '但本例题里同时有静态,因此关了也不崩溃,因为不在真正卸载DLL,因为还有静态加载。
End Sub 

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多