简体   繁体   English

C ++ DLL可从32位Excel VBA运行,但为64位Excel重新编译时则无法运行

[英]C++ DLL works from 32 bit Excel VBA, but not when recompiled for 64 bit Excel

Using Visual Studio 2010 Premium I have built a c++ DLL in both 32 and 64 bit flavors for calling from Excel 2010 visual basic. 使用Visual Studio 2010 Premium,我已经构建了32位和64位版本的c ++ DLL,用于从Excel 2010 Visual Basic进行调用。 It works great with 32 bit Excel, but with 64 bit Excel I get the dreaded "Error 53, file not found". 它在32位Excel上很好用,但是在64位Excel上,我得到了可怕的“错误53,找不到文件”。 The DLL contains just two exported functions, one function runs ok with Excel-64 but the other function triggers the error. DLL仅包含两个导出的函数,一个函数可以在Excel-64上正常运行,但另一个函数会触发错误。 Dependency Walker did not help me. Dependency Walker并没有帮助我。 The problem ought to be a missing dependency, but I can't figure out what it is. 该问题应该是缺少的依赖项,但我不知道这是什么。

Nevermind. 没关系。 It was a boneheaded mistake with management of folder paths. 管理文件夹路径是一个严重的错误。 I was well aware that that this sort thing causes an Error 53, but I thought that wasn't my problem, but it was. 我很清楚这种问题会导致错误53,但我认为这不是我的问题,但确实是。

For Excel VBA to be able to load the DLL, either CurDir() has to be set to the folder containing the DLL before calling a function in it, or the entire path needs to be in the VBA Declare statement. 为了使Excel VBA能够加载DLL,必须在其中调用函数之前将CurDir()设置到包含DLL的文件夹中,否则整个路径都必须在VBA Declare语句中。 I thought I was changing the CurDir before the call, but I wasn't. 我以为我在通话之前要更换CurDir,但是没有。

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

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