Visual C++指示设备
我想使用 Visual C++ 为线性执行器控制板创建自定义程序。我想使用第 6-10 页的 LAC 高级配置 中指定的功能和控制值。
我有以下代码来加载 dll 文件。
#include <windows.h> // This is a windows header file. The functions I mentioned above are declared here
#include <mpusbapi.h> // This is the header file supplied. It declares the function prototypes that are defined in the DLL
int main(int argc, char* argv)
{
// Try to load the library
HMODULE mpbusDLL = NULL;
mpbusDLL = LoadLibrary(L"mpusbapi.dll");
if (mpbusDLL != NULL) {
// If the library could be loaded, then load the functions using GetProcAddress()
// Load the function 'MPUSBOpen' from the DLL
MPUSBOpen = (HANDLE(*)(DWORD, PCHAR, PCHAR, DWORD, DWORD)) GetProcAddress(mpbusDLL, "_MPUSBOpen");
}
但是
,LAC 驱动程序附带 mpusbapi.dll,但没有 mpusbapi.h 文件。 mpusbapi.h 文件是否可能位于 .dll 文件内?如果是这样,我该如何利用它。
截至目前,当我尝试构建程序时,我收到致命错误 C1083:无法打开包含文件:'mpusbapi.h':没有这样的文件或目录
。
编辑 1 & 2:
找到 mpusbapi .h 文件!如果有人需要的话...
I want to use Visual C++ to create a custom program for a linear actuator control board. I want to use the functions and control values specified in LAC advanced config on pages 6-10.
I have the following code to load the dll file.
#include <windows.h> // This is a windows header file. The functions I mentioned above are declared here
#include <mpusbapi.h> // This is the header file supplied. It declares the function prototypes that are defined in the DLL
int main(int argc, char* argv)
{
// Try to load the library
HMODULE mpbusDLL = NULL;
mpbusDLL = LoadLibrary(L"mpusbapi.dll");
if (mpbusDLL != NULL) {
// If the library could be loaded, then load the functions using GetProcAddress()
// Load the function 'MPUSBOpen' from the DLL
MPUSBOpen = (HANDLE(*)(DWORD, PCHAR, PCHAR, DWORD, DWORD)) GetProcAddress(mpbusDLL, "_MPUSBOpen");
}
}
However, the LAC drivers comes with a mpusbapi.dll but no mpusbapi.h file. Is it possible that the mpusbapi.h file is within the .dll file? And if so, how can I utilize it.
As of now I get fatal error C1083: Cannot open include file: 'mpusbapi.h': No such file or directory
when I try to build the program.
EDIT 1 & 2:
Found the mpusbapi.h file! If anyone out there needs it...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
头文件 (mpusbapi.h) 可能随 SDK 一起提供。
如果没有SDK,您至少应该获得一个API文档并手动声明要从DLL导入的函数。
您如何知道 MPUSBOpen 函数需要 DWORD、PCHAR 等参数并返回 HANDLE?
The header file (mpusbapi.h) is probably delivered with a SDK.
If there is no SDK, you should get at least an API documentation and manually declare the functions to be imported from the DLL.
How did you know the MPUSBOpen function requires the DWORD, PCHAR and so on parameters and returns a HANDLE?