VB6 - DLL Not Found

I am trying to load a DLL in VB6 using the command

Private Declare Function myFuncLib "myDLL.dll" (ByVal file_name_in As String, _ ByVal file_name_out As String) As Long

But as soon as I run the program, it will display a window with the text ":" Runtime Error: 53 Cannot find: myDLL.dll "

The DLL is placed in the same project directory.

If I put myDLL.dll in the system32 folder, it works, but I do not want to do this, I would like to put the DLL in the same project folder.

Is there any way to solve this problem?

thanks

+4
source share
5 answers

My psychic abilities predict that you are working with the VB6 IDE - because the built-in EXE will find the DLLs in the application directory (the same directory as exe).

  • When you run the VB6 IDE, it will find the DLLs from the application directory ... but it considers the application directory to be the directory containing the VB6 IDE itself: (
  • One way is to change the current working directory to the VBP directory before trying to use the DLL. For instance. Chdrive App.Path: Chdir App.Path (air code)
  • EDIT Next comment from Beppe. Another workaround you can try is simply on your development machine to put a copy of the DLL in the same directory where the VB6 IDE is installed. Probably C:\Program Files\Microsoft Visual Studio\VB98\ You can put the DLL with your built-in EXE on user machines / production machines.
+7
source

You need to register your DLL first.

Shell "regsvr32.exe / s" and path

Where the "path" is the path to the DLL. If the DLL is placed in the same directory, you can install:

path = App.path and "/myDLL.dll"

0
source

Decided to use "Depends"

There was an unsatisfied dependency in the DLL, but obviously it returned an error at the first entry point into the DLL.

Thank you all

0
source

Declare a link to the Kernel32.lib SetDllDirectory function:

 Private Declare Function SetDllDirectory Lib "Kernel32" Alias "SetDllDirectoryA" (ByVal path As String) As Long 

Then install the Dll directory as follows:

 SetDllDirectory App.path 
0
source

As Beppe said in their answer , use

 Depends yourdll.dll 

Should you use other dlls? next to their name, this means that they are absent.
Usually it will be one of the Microsoft C ++ dll Debug ie MSVCR120D.DLL

0
source

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


All Articles