代码之家  ›  专栏  ›  技术社区  ›  Paul Karam

如何从DLL创建类的新实例?

  •  0
  • Paul Karam  · 技术社区  · 6 年前

    我正在转换用编码的旧应用程序 VB6 VB.NET .

    在旧的应用程序中,我使用的是第三方 DLL 文件。我们称之为 ThirdParty.dll .

    我的习惯之一 ThirdParty.DLL 就像在 vb6 以下内容:

    Dim MyApi as new x.y 'referenced from the ThirdParty.dll
    Dim vReturnCode as Long
    
    vReturnCode = MyAPI.InitialiserCles(a, b, c, d, e) 'consider a,b,c,d,e variables declared and initiaited.
    

    在旧应用程序中,这将返回一个结果 Long .

    现在,我需要用同样的方法 第三方.dll 在我的新的 vb.net版 应用程序。

    我创造的是:

    Public Class ThirdPartyAPI
        Private Declare Function InitialiserCles Lib "ThirdPartyFolder\ThirdParty" (a As String, b As String, c As String, d As String, ByRef e As String) As Long
    
        Public Function InitializeKey(a As String, b As String, c As String, d As String, ByRef e As String) As Long
            Return InitialiserCles(a, b, c, d, e)
    
        End Function
    End Class
    

    现在,当我想使用它时,我是这样做的:

    Dim MyApi as new ThirdPartyAPI
    Dim result as MyApi.InitialiserCles(a,b,c,d,e) 'consider again variables are well declared/initiated.
    

    我收到以下错误:

    在dll ThirdpartyFolder\Thirdparty中找不到dll入口点“Initializers”

    我想这是因为我们实际上正在创建 x.y 从该dll,然后调用函数 InitialiserCles (在旧应用(vb6)中)。我也没能做到 vb.net版 .我错过了什么?

    1 回复  |  直到 6 年前
        1
  •  0
  •   Paul Karam    6 年前

    regsvr32 注意我必须使用里面的那个 SysWOW64

    regsvr32 "FullPath\ThirdParty"