代码之家  ›  专栏  ›  技术社区  ›  bugmagnet

Vista和7下Visual Studio 2008中Visual Studio 6类型库的处理方式是否不同?

  •  0
  • bugmagnet  · 技术社区  · 14 年前

    我在Visual Studio 6 C++中编写了一个标准的DLL。我还编写了一个typelib,以便它可以直接在VB6中使用,而不是通过Declare。

    它在Windows XP下的VB6中运行良好。

    当我把DLL和TLB放到Vista和Windows7中时,就不起作用了。在那里.TLB在 REGTLIB 但在Visual Studio 2008中唯一可见的符号是 Attribution 不变。

    我试图模拟的技术可以在 How To Make C DLL More Accessible to VB with a Type Library . 是不是这种技术不再适用了???

    (缩写)ODL代码复制如下。知道怎么回事吗?

    // This is the type library for BOBDE.dll
    [
        // Use GUIDGEN.EXE to create the UUID that uniquely identifies
        // this library on the user's system. NOTE: This must be done!!
        uuid(EE090BD0-AB6C-454c-A3D7-44CA46B1289F),
        // This helpstring defines how the library will appear in the
        // References dialog of VB.
        helpstring("BOBDE TypeLib"),
        // Assume standard English locale.  
        lcid(0x0409),
        // Assign a version number to keep track of changes.
        version(1.0)
    ]
    library BOBDE
    {
        // Now define the module that will "declare" your C functions.
    [helpstring("Functions in BOBDE.DLL"), version(1.0),dllname("BOBDE.dll")]   
        module BOBDEFunctions
        {
    [helpstring("Blowfish Encode ASCII for ANSI"), entry("BEA_A")] 
        void __stdcall BEA_A( [in] BSTR p1, [in] BSTR p2, [out,retval] BSTR* res );
        // other very similar functions removed for the sake of brevity
    const LPSTR Attribution = "This product includes cryptographic software written by Eric Young (eay@cryptsoft.com)"; 
        } // End of Module
    }; // End of Library
    
    2 回复  |  直到 14 年前
        1
  •  2
  •   Hans Passant    14 年前

    这里的问题是,您不仅更改了操作系统,还更改了开发工具。如果在Win7上运行VB6,它应该仍然可以工作。但是Visual Studio 2008支持VB.NET 非常 不同于VB6的语言。它只支持“true”类型库,即COM使用的类型库。

    <DllImport("bobde.dll")> _
    Function BEA_A( _
          <MarshalAs(UnmanagedType.BStr)> ByVal p1 As String, _
          <MarshalAs(UnmanagedType.BStr)> ByVal p2 As String) _
        As <MarshalAs(UnmanagedType.BStr)> String
    End Function
    

    无需为此注册类型库。在C++/CLI语言中编写托管类包装器将是另一种方法。

        2
  •  0
  •   Kris Erickson    14 年前

    创建typelib而不仅仅是在VB6中声明函数有什么原因吗?放

    Private Declare Function BEA_A Lib "bobde.dll" _
    (ByVal p1 As String, ByVal p2 As String) As String 
    

    在模块的顶部看起来简单得多。