Use C ++ DLL with VB6

I just created a DLL for my boss in MSVC ++ 2010. I selected the "New Win32 DLL" with the option "Export characters", so everything is completely standard. The new project files have a certain predefined export, a class, its constructor, a global function and a variable with dummy values, and a dllmain.cpp file with the APIENTRY function. I have not changed anything.

Now my boss wants to use the exported stuff in his VB6 project. He started the VB6 project, made the “Project” - “Links” menu (translated from German into English, so it can be a little different, but I'm sure you know what I mean) and selected the DLL file, also as he says he usually does.

However, VB6 cannot enable it; instead, the error message "cannot include the DLL file" appears (without a real reason). The same thing happened with the standard new DLL project with Visual C ++ 6. My boss thinks this may be because the characters are not actually exported, or VB6 needs special declarations. Does anyone know what the problem is?

+3
source share
5 answers

Yes, VB6 does not work like that. You need to declare DLL functions in VB code something 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

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.

: , ++ DLL "__declspec".

+6

, , . DLL, voodoo, VB6 DLL-, VB6.

+2

DLL ++ VB6 - COM.

+1

DLL VB, Declare. DLL ActiveX .

+1

If it is not a COM library, you only need to export the C function with __stdcall. You may need to create a .def file for them (http://msdn.microsoft.com/en-us/library/d91k01sh(VS.80).aspx). Also use a dependency walker, for example. depends.exe to find out what functions were exported and with what names.

+1
source

Source: https://habr.com/ru/post/1788519/


All Articles