使用C ++ DLL与VB6 [英] Use C++ DLL with VB6

查看:167
本文介绍了使用C ++ DLL与VB6的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚为MSVC ++ 2010中的老板创建了一个DLL。我选择新Win32 DLL选项导出符号,所以,一切都是完全标准。在新的项目文件中有一些预定义的导出,一个类,它的构造函数,一个具有bogus值的全局函数和变量以及一个具有APIENTRY函数的文件dllmain.cpp。我什么也没有改变。

I just created a DLL for my boss in MSVC++2010. I selected "New Win32 DLL" with option "Export symbols", so, everything is completely standard. There are some predefined exports in the new project files, a class, its constructor, a global function and variable with bogus values and a file dllmain.cpp with an APIENTRY function. I changed nothing yet.

现在我的老板想在他的VB6项目中使用导出的东西。他开始了一个VB6项目,菜单项目 - 链接(从德语翻译成英语,所以它可能有点不同,但我相信你知道我的意思),并选择一个DLL文件,正如他说通常是。

Now my boss wants to use the exported things in his VB6 project. He started a VB6 project, did menu "Project" - "Links" (translated from German to English, so it might be somewhat different but I'm sure you know what I mean) and selected a DLL file, just as he says he usually does.

但是,VB6无法包含它,而是显示一个错误消息无法包括DLL文件(没有真正的原因)。同样的情况发生在一个标准的新的DLL项目从Visual C ++ 6.我的老板认为这可能是因为符号没有真正导出或VB6需要一些特殊的声明。有没有人知道问题是什么?

However, VB6 fails to include it, instead showing an error message "could not include DLL file" (no real reason given). The same occurred with a standard new DLL project from Visual C++ 6. My boss thinks it might be because the symbols are not really exported or VB6 needs some special declarations. Does anyone know what the problem is?

推荐答案

是的,VB6不工作。你需要在VB代码中声明DLL函数有点像这样:

Yeah, VB6 doesn't work like that. You need to declare the DLL functions in your VB code somewhat like this:

Private Declare Function WinHelp Lib "user32" Alias "WinHelpA" _
  (ByVal hwnd As Long, ByVal lpHelpFile As String, _
  ByVal wCommand As Long, ByVal dwData As Long) As Long

您可以用MyCPlusPlusDLL.dll替换user32,并使用DLL中的实际方法名称和签名等。

You would replace "user32" with "MyCPlusPlusDLL.dll" and use the actual method names and signatures etc. from your DLL. Then put the DLL in your /System folder and you should be good to go.

注意:这是假设你的C ++ DLL中的方法是用__declspec声明的, 。

Note: this is assuming that the methods inside your C++ DLL are declared with "__declspec".

这篇关于使用C ++ DLL与VB6的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆