windows VB6 - 找不到 DLL

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5234386/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 16:22:12  来源:igfitidea点击:

VB6 - DLL cannot be found

windowsdllvb6

提问by Beppe

I'm trying to load a DLL in VB6 using the command

我正在尝试使用以下命令在 VB6 中加载 DLL

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

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 pop-up a box with the text": "Run time error: 53 Cannot find: myDLL.dll"

但是一旦我运行程序,它就会弹出一个带有文本的框:“运行时错误:53 找不到:myDLL.dll”

The DLL is placed in the same directory of the project.

DLL 放置在项目的同一目录中。

If I put myDLL.dll in the system32 folder it works, but I don't want to do it, I would like to place the dll in the same folder of the project.

如果我将 myDLL.dll 放在 system32 文件夹中它可以工作,但我不想这样做,我想将 dll 放在项目的同一文件夹中。

Is there a way to solve this problem?

有没有办法解决这个问题?

Thanks

谢谢

回答by MarkJ

My psychic powers predict you are running from the VB6 IDE - because a built EXE wouldfind DLLs in the app directory (the same directory as the exe).

我的超能力预测您正在从 VB6 IDE 运行 - 因为构建的 EXE在 app 目录(与 exe 相同的目录)中找到 DLL。

  • When you run from the VB6 IDE, it willfind DLLs from the app directory... but it considers the app directory to be the directory containing the VB6 IDE itself :(
  • One workaround is to change the current working directory to be the VBP directory before you try to use the DLL. E.g. Chdrive App.Path: Chdir App.Path(air code)
  • EDITFollowing comment from Beppe. Another workaround you could try is, just on your development machine, 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 EXE on the user machines / production machines.
  • 当您从 VB6 IDE 运行时,它从 app 目录中找到 DLL...但它认为 app 目录是包含 VB6 IDE 本身的目录:(
  • 一种解决方法是在尝试使用 DLL 之前将当前工作目录更改为 VBP 目录。例如Chdrive App.Path: Chdir App.Path(航空代码)
  • 编辑以下来自 Beppe 的评论。您可以尝试的另一种解决方法是,仅在您的开发机器上,将 DLL 的副本放在安装 VB6 IDE 的同一目录中。可能C:\Program Files\Microsoft Visual Studio\VB98\您可以将带有构建的 EXE 的 DLL 放在用户机器/生产机器上。

回答by Mark Dietel

Declare a reference to Kernel32.lib SetDllDirectory function:

声明对 Kernel32.lib SetDllDirectory 函数的引用:

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

Then set the Dll directory as follows:

然后设置Dll目录如下:

SetDllDirectory App.path

回答by Steve

As Beppe said in their answer, use

正如 Beppe 在他们的回答中所说,使用

Depends yourdll.dll

If you seel other DLLS with ? next to their name it means they are missing.
Usually it will be one of the Microsoft C++ Debug dll i.e MSVCR120D.DLL

如果您使用 ? 在他们的名字旁边,这意味着他们失踪了。
通常它是 Microsoft C++ Debug dll 之一,即 MSVCR120D.DLL

回答by Ronald

You need to register your DLL first..

你需要先注册你的DLL..

Shell "regsvr32.exe /s " & path

外壳“regsvr32.exe /s”和路径

Where "path" is the path of the DLL.. If the DLL is placed in the same directory, then you can set:

其中“path”是DLL的路径。如果DLL放在同一个目录下,那么可以设置:

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

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

回答by Beppe

Solved using "Depends"

使用“依赖”解决

There was an unsatisfied dependency in the DLL, but obviously it was returning the error on the first DLL entry point.

DLL 中有一个不满意的依赖项,但显然它在第一个 DLL 入口点返回错误。

Thank you all

谢谢你们