VBA找不到我的DLL,尽管硬编码位置。 [英] VBA cannot find my DLL, despite hardcoding location.

查看:425
本文介绍了VBA找不到我的DLL,尽管硬编码位置。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用C ++创建一个简单的DLL,我可以使用从VBA代码。然而,虽然它在我的开发计算机上工作,当尝试访问不同的计算机上的DLL,VBA说明没有找到DLL文件,尽管硬编码的路径。

I am using C++ to create a simple DLL that I can use from VBA code. However, while it works on my development computer, when attempting to access the DLL on different computers, VBA states the DLL File was not found, despite hardcoding the path in.

我的DLL看起来像这样(使用Visual C ++ 2010 Express作为Win32 dll项目创建):

My DLL looks like this (created with Visual C++ 2010 Express as a Win32 dll project):

DEF文件:

LIBRARY "squareNumber"
EXPORTS
squareNumber


$ b b

Function.cpp:

Function.cpp:

double __stdcall squareNumber(double & x)
{
    return x*x;
}

VBA代码如下所示:

The VBA code looks like this:

Public Declare Function squareNumber Lib "C:\MySimpleDLL.dll" (ByRef number As Double) As Double

Sub test()
    MsgBox squareNumber(2)
End Sub

,我编码的dll错了,还是它的VBA的问题?

I am very new to C++ DLLs, did I code the dll wrong, or is it VBA's problem?

使用RegSvr32也会产生模块[dllpath]加载失败,确保二进制存储指定的路径或调试它检查二进制或依赖.DLL文件的问题。

Using RegSvr32 also yields "The module [dllpath] failed to load. Make sure the binary is stored at the specified path or debug it to check for problems with the binary or dependent .DLL files."

推荐答案

对开发计算机上存在的其他DLL没有依赖性,而是在目标计算机上。当操作系统加载你的DLL,但却找不到依赖的DLL,它报告相同的无法找到文件的错误,使你认为它找不到你的DLL,当它真的做到了。如果是这样,那么你需要分发这些额外的DLL或删除它们的依赖。

It sounds like your DLL has dependancies on other DLLs that exist on your development machine but not on the target machine. When the OS loads your DLL but then can't find the dependent DLLs, it reports the same "cannot find file" error, making you think it cannot find your DLL when it really did. If that is the case, then you need to either distribute those extra DLLs or remove the dependencies on them.

这篇关于VBA找不到我的DLL,尽管硬编码位置。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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