我对Visual C ++很陌生......我目前正在研究的项目是使用VC ++创建Digibee接受的输入日志。
有关Digibee的信息:http://www.pc-control.co.uk/digibee_info.htm本手册包含加载DLL,调用函数等的基本代码。
对于一些函数,代码似乎工作得很好(经过一些修改)......问题是:
Init() - 不接受任何参数,但是当我编码时,我必须传递一个参数才能工作;我传递0
ReadAnalogueInputs() - 应该接受4个参数但是当我传递4时,它说的参数太多了。当我成功传递一个.builds然后给出System.AccessViolation异常时工作正常。
请帮助我!
// Header file for use with dgb.dll
typedef bool (*Type_InitDgb)();
typedef bool (*Type_ReadInputs)(int *inputs);
typedef bool (*Type_SetOutputs)(int outputs);
typedef bool (*Type_ReadAnalogueInputs)(int *aip1, int *aip2, int *aip3, int *aip4);
typedef bool (*Type_SetSensitivity)(int sensitivity);
//源文件
private: System::Void btn_Click(System::Object^ sender, System::EventArgs^ e) {
HINSTANCE DgbHandle = LoadLibrary(TEXT("dgb.dll"));
if (DgbHandle==NULL)
btn->Text="Error";
else
{
btn->Text="Initialized";
this->progressBar1->Value=100;
}
textBox1->Text="Obtaining pointers\n";
TypeInitDgb InitDgb;
TypeSetOutputs SetOutputs;
TypeReadInputs ReadInputs;
TypeReadAnalogueInputs ReadAnalogueInputs;
TypeSetSensitivity SetSensitivity;
InitDgb = (TypeInitDgb)GetProcAddress(HMODULE(DgbHandle),"InitDgb");
SetOutputs = (TypeSetOutputs)GetProcAddress(HMODULE(DgbHandle),"SetOutputs");
ReadInputs = (TypeReadInputs)GetProcAddress(HMODULE(DgbHandle),"ReadInputs");
ReadAnalogueInputs = (TypeReadAnalogueInputs)GetProcAddress(HMODULE(DgbHandle),"ReadAnalogueInputs");
SetSensitivity = (TypeSetSensitivity)GetProcAddress(HMODULE(DgbHandle),"SetSensitivity");
this->progressBar2->Value=100;
textBox1->Text="Pointers obtained";
status=InitDgb(0);
if(status==1)
{
textBox1->Text="Digibee initialized";
this->progressBar3->Value=100;
SetOutputs(LPCTSTR(0x0001));
//SetOutputs(LPCSTR(15));
}
int a1,a2,a3,a4;
ReadAnalogueInputs(LPCTSTR(&a1));
}