简体   繁体   English

在Excel 2010中从VBA调用的C ++ DLL仅在管理员模式下工作

[英]C++ DLL called from VBA in Excel 2010 only works in administrator mode

I have created a simple dll in Visual Studio 2012 that performs a calculation. 我在Visual Studio 2012中创建了一个简单的dll,用于执行计算。 I am calling this dll from VBA in Excel 2010 using the following syntax: 我正在使用以下语法从Excel 2010中的VBA调用此dll:

Declare Sub MyFunction Lib "MyDll.dll" (ByRef param1 As Double, ByVal param2 As Double)

This function works perfectly on my development machine. 此功能可以在我的开发机器上完美运行。 When I try to run this dll on another computer, I get the following error: 当我尝试在另一台计算机上运行此dll时,出现以下错误:

Run-time error '53': File not found: MyDll.dll

However, when I run Excel (on another computer) in administrator (elevated) mode, I don't get this error and everything works perfectly. 但是,当我以管理员(提升)模式运行Excel(在另一台计算机上)时,我没有收到此错误,一切正常。

Is there any way I can get this to work without having the user run Excel as an administrator? 有什么办法可以让用户无需管理员运行Excel就能使它正常工作?

From what I can guess your DLL is not in the working directory, PATH variable directory or system directory. 根据我的猜测,您的DLL不在工作目录,PATH变量目录或系统目录中。 Excel is not looking in the directory your DLL is so you need to move your DLL into the system directory, one of the PATH variable directories or excels' working directory. Excel不在DLL目录中查找,因此您需要将DLL移至系统目录,PATH变量目录之一或excels的工作目录中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM