我正在尝试使用 c++ 控制 MotorBee,问题是我使用的是 MotorBee “mtb.dll”附带的 dll 文件
我正在尝试将 dll 中的函数加载到我的 C++ 程序中,如下所示:
#include "stdafx.h"
#include <iostream>
#include "mt.h"
#include "windows.h"
using namespace std;
HINSTANCE BeeHandle= LoadLibrary((LPCWSTR) "mtb.dll");
Type_InitMotoBee InitMotoBee;
Type_SetMotors SetMotors;
Type_Digital_IO Digital_IO;
int main() {
InitMotoBee = (Type_InitMotoBee)GetProcAddress( BeeHandle, " InitMotoBee");
SetMotors =(Type_SetMotors)GetProcAddress(BeeHandle, " SetMotors");
Digital_IO =(Type_Digital_IO)GetProcAddress(BeeHandle, " Digital_IO "); InitMotoBee();
SetMotors(0, 50, 0, 0, 0, 0, 0, 0, 0);
system("pause");
return 0;
}
我收到一条错误消息,说我正在尝试读取内存中的地址 0x00000000,当我尝试计算 BeeHandle 时,它显示 0x0 地址(尝试检查句柄值)示例错误:
First-chance exception at 0x00000000 in 111111.exe: 0xC0000005: Access violation reading location 0x00000000.
First-chance exception at 0x6148f2b4 in 111111.exe: 0xC0000005: Access violation reading location 0x00000000.
First-chance exception at 0x6148f2b4 in 111111.exe: 0xC0000005: Access violation reading location 0x00000000.
First-chance exception at 0x6148f2b4 in 111111.exe: 0xC0000005: Access violation reading location 0x00000000.
First-chance exception at 0x6148f2b4 in 111111.exe: 0xC0000005: Access violation reading location 0x00000000.
感谢您的帮助,