通过 VBA 访问 DLL
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5822438/
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
Accessing DLLs through VBA
提问by Kshitij Saxena -KJ-
How can I access the functions inside a third-party DLL from VBA (Excel)? Also, is there a way to see what all functions are available inside a DLL?
如何从 VBA (Excel) 访问第三方 DLL 中的函数?另外,有没有办法查看 DLL 中所有可用的函数?
回答by Justin
To call a function in a third-party DLL, you need to use the Declare
statement. For example:
要调用第三方 DLL 中的函数,您需要使用该Declare
语句。例如:
Private Declare Function GetTempPath Lib "kernel32" _
Alias "GetTempPathA" (ByVal nBufferLength As Long, _
ByVal lpBuffer As String) As Long
See How to: Access DLLs in Excelon MSDN for more information.
有关详细信息,请参阅如何:访问MSDN上的 Excel 中的 DLL。
To list the functions that are available, take a look at the Dependency Walkertool, which will list the exported functions from DLLs (and lots of other information).
要列出可用的函数,请查看Dependency Walker工具,该工具将列出从 DLL 导出的函数(以及许多其他信息)。