一、Led的dll调用方法步骤
1.1将创建好的MFC工程,修改为多字节,操作如下:
【配置属性】-【常规】-【字符集】-【使用多字节字符集】
1.2将MiniLED.h,MiniLED.cpp,MiniLED.dll三个文件加入新建工程的目录下,并且加入到工程中如下图所示:
1.3将MiniLED.h头文件加入LedTest1Dlg.h所在头文件:
1.4在LedTest1Dlg.cpp源文件的初始化函数OnInitDialog()里面,加入函数LoadMiniLEDdll(),如下图所示:
1.5此时,可以调用动态库MiniLED.dll里面的函数,如下所示:
1.5.1代码图片:
1.5.2代码程序:
unsigned short mDevID= 1;
int a2 =MC_ComInitial(mDevID, 9, 38400, 2, 4, 1);//串口初始化 LedNum:卡地址
charstr1[128] = "29℃ 42% 25% 370 415";
charstr2[128] = "31℃ 45% 28% 625 426";
charstr3[128] = "27℃ 39% 22% 346 403";
charstr4[128] = "30℃ 41% 24% 361 411";
charstr5[128] = " 1号棚环境信息";
BYTE *Str1, *Str2, *Str3, *Str4, *Str5;
Str1 = (BYTE *)str1;
Str2 = (BYTE *)str2;
Str3 = (BYTE *)str3;
Str4 = (BYTE *)str4;
Str5 = (BYTE *)str5;
int a20 =MC_ChangeGroup(mDevID, 0, 0, 0);//更改当前节目组
int a5 =MC_ShowString(mDevID, 0, 32, 192, 16, 0, 0, 1, Str1, 2);//显示字符串
int a6 = MC_ShowString(mDevID,0, 48, 192, 16, 0, 0, 1, Str2, 2);//显示字符串
int a7 =MC_ShowString(mDevID, 0, 64, 192, 16, 0, 0, 1, Str3, 2);//显示字符串
int a8 =MC_ShowString(mDevID, 0, 80, 192, 16, 0, 0, 1, Str4, 2);//显示字符串
int a9 =MC_ShowString(mDevID, 0, 96, 192, 16, 0, 0, 1, Str5, 2);//显示字符串
MC_Close(mDevID);//释放Com口ID