是的Visual Studio 6种类型库在Visual Studio 2008中不同的处理下,Vista和Windows 7?

StackOverflow https://stackoverflow.com/questions/4020592

  •  26-09-2019
  •  | 
  •  

我已经在Visual Studio 6个C编写的标准的DLL ++。我也写一个类型库去用它,这样它可以直接在VB6,而不是通过申报使用。

它工作在Windows XP中VB6的罚款。

什么行不通是,当我把DLL和TLB在Vista和Windows7。在那里,.TLB寄存器罚款REGTLIB但在Visual Studio 2008是唯一可见的符号是Attribution不变。

我试图仿效该技术在发现如何使C DLL更容易获得VB用类型库。是它的情况下,这种技术不再适用???

在(缩写)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
有帮助吗?

解决方案

这里的问题是,你不只是改变了操作系统,你也改变了你的开发工具。如果你Win7上运行VB6它应该仍然工作。但是,Visual Studio 2008的支持VB.NET,一个的非常的不同,VB6语言。它仅支持“真”类型库,所述那些COM用途。

调用从DLL导出函数需要使用内置到.NET的P /调用编组。退房DllImportAttribute和MSDN Library中的VB.NET Declare语句。该功能的声明应该像这样:

<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语言是另一种方法。

其他提示

您正在创建类型库,而不只是声明函数在VB6的原因吗?把

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

在您的模块的顶部似乎简单了很多。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top