VS生成的程序在别的电脑调用DLL失败,在xp上提示不是有效的win32程序

mcfly29 2017-07-06 04:58:25
BOOL CMeasureCalculateFrame::callDll()
{
HINSTANCE hDLL;
hDLL=LoadLibrary(L"ADIO16.dll");//加载DLL
typedef unsigned int(WINAPI *m_FindDevice)(); //定义一个与OpenDevice()函数接受参数类型和返回值均相同的函数指针类型
typedef unsigned int(WINAPI *m_OpenDevice)(unsigned int ID); //定义一个与ReadDeviceHID2BUF()函数接受参数类型和返回值均相同的函数指针类型
typedef unsigned int(WINAPI *m_ReadDevice)(unsigned int ID, unsigned int *ADBuf, unsigned int Len, unsigned int *DAbuf,unsigned int *CNbuf, unsigned int *DIO);
//定义一个与WriteDeviceHIDEX()函数接受参数类型和返回值均相同的函数指针类型
typedef unsigned int(WINAPI *WriteDevice) (unsigned int ID, unsigned int CMD, unsigned int DO0, unsigned int DO1, unsigned int DO2, unsigned int DO3);
m_FindDevice FindD;
m_OpenDevice OpenD;
m_ReadDevice ReadDataViaHID2BUF;
WriteDevice WriteData2DO;
//newMainFrame->m_measure=1;

// bool DI0;bool DI1;//float CH0;float CH1;
unsigned int ADBuf[4096]={0};
unsigned int DAbuf [2]={0};
unsigned int CNbuf [2]={0};
unsigned int DIO [2]={0};
float CH0;//CH1;
float avgCHO=0;
unsigned int DeviceId=1;
int fineResult;
int openResult;
// int fineResult
CString strTemp;
if(hDLL)
{
//AfxMessageBox(L"找到了dll文件");
FindD=(m_FindDevice)GetProcAddress(hDLL,"FindDevice");
OpenD=(m_OpenDevice)GetProcAddress(hDLL,"OpenDevice");
ReadDataViaHID2BUF =(m_ReadDevice)GetProcAddress(hDLL,"m_ReadDeviceHID2BUF");
WriteData2DO=(WriteDevice)GetProcAddress(hDLL,"WriteDeviceHIDEX");
if(FindD) //1查找设备
{
fineResult=FindD();
//strTemp.Format(L"%d",fineResult);
// SetDlgItemText(IDC_EDIT_value,strTemp); //找到设备,返回设备数量1
if(fineResult==1)
{
//AfxMessageBox(L"找到了设备");
}
else
{
KillTimer(newMCF->winStatus);
AfxMessageBox(L"没有找到设备,请检查设备是否成功连接");
//newMCF->winStatus=0; //设置窗口状态为0

GetDlgItem(IDB_BUTTON_START)->EnableWindow(TRUE); //启用开始测量按钮
GetDlgItem(IDB_BUTTON_STOP)->EnableWindow(FALSE); //禁用停止测量按钮
//GetDlgItem(IDB_BUTTON_NEW_MEASUR)->EnableWindow(TRUE);
}
}
if(fineResult==1&&OpenD) //2打开设备
{
openResult=OpenD(DeviceId);
//strTemp.Format(L"%d",fineResult);
//SetDlgItemText(IDC_EDIT_avgValue,strTemp); //返回1打开设备成功,0失败
if(openResult==1)
{
//AfxMessageBox(L"打开了设备");
}
else{
//KillTimer(newMCF->winStatus);
AfxMessageBox(L"打开设备失败");

}
}
if(openResult==1&&ReadDataViaHID2BUF) //3)AI、DI采集
{
int res= ReadDataViaHID2BUF(0, ADBuf, 1024, DAbuf , CNbuf , DIO);
//strTemp.Format(L"%d",res);
// SetDlgItemText(IDC_EDIT_read,strTemp);

for (int i=0 ; i<256 ; i++)
{
int X0= ADBuf [2*i];
//int X1= ADBuf [2*i+1];
CH0=X0*9.83/4096;
avgCHO=avgCHO+CH0;

}
avgCHO=avgCHO/256;
//UpdateData(TRUE);
switch(newMCF->winStatus)
{
case 1:
Measure->m_calculate_NC.Format(L"%.8f",avgCHO);
//::MessageBox(NULL,Measure->m_calculate_NC,L"编辑框内容为",MB_OK);
//SetDlgItemText(IDC_Textbox_NC,Measure->m_calculate_NC);
SetDlgItemText(IDC_EDIT_MeasureValue,Measure->m_calculate_NC);
newMCF->m_firstMessageValue+=avgCHO;
//SetDlgItemText(IDC_EDIT_value,m_value);
break;
case 2:
Measure->m_calculate_NR.Format(L"%.8f",avgCHO);
//::MessageBox(NULL,Measure->m_calculate_NC,L"编辑框内容为",MB_OK);
//SetDlgItemText(IDC_Textbox_NR,Measure->m_calculate_NR);
SetDlgItemText(IDC_EDIT_MeasureValue,Measure->m_calculate_NR);
newMCF->m_secondMessageValue+=avgCHO;
//SetDlgItemText(IDC_EDIT_value,m_value);
break;
case 3:
Measure->m_calculate_HC.Format(L"%.8f",avgCHO);
//::MessageBox(NULL,Measure->m_calculate_HC,L"编辑框内容为",MB_OK);
//SetDlgItemText(IDC_Textbox_HC,Measure->m_calculate_HC);
SetDlgItemText(IDC_EDIT_MeasureValue,Measure->m_calculate_HC);
//if(newMCF->startStatus==1)
//newMCF->m_thirdMessageValue=0;
newMCF->m_thirdMessageValue+=avgCHO;
//SetDlgItemText(IDC_EDIT_value,m_value);
break;
case 4:
Measure->m_calculate_HR.Format(L"%.8f",avgCHO);
//::MessageBox(NULL,Measure->m_calculate_HC,L"编辑框内容为",MB_OK);
//SetDlgItemText(IDC_Textbox_HR,Measure->m_calculate_HR);
SetDlgItemText(IDC_EDIT_MeasureValue,Measure->m_calculate_HR);
//if(newMCF->startStatus==1)
//newMCF->m_fourthMessageValue=0;
newMCF->m_fourthMessageValue+=avgCHO;
//SetDlgItemText(IDC_EDIT_value,m_value);
break;
default:
break;
}
//UpdateData(FALSE);
return true;
}
if(WriteData2DO) ////4)DO控制
{
int wResult=WriteData2DO(1,0XD0,0x03,0,0,0);
//strTemp.Format(L"%d",wResult);
//SetDlgItemText(IDC_EDIT_write,strTemp);
}

}
else
{
AfxMessageBox(L"缺少dll文件");
KillTimer(newMCF->winStatus);
return false;
}
FreeLibrary(hDLL);//释放已经加载的DLL模块
}

这是调用DLL的函数,一直提示没有找到设备,我是直接把debug文件拷到其他电脑的,电脑上有安装vs的,是不是少了什么文件?
debug文件拷贝到XP系统,没法打开程序,提示不是有效的win32程序,xp没有安装vs的,这又是什么问题呢?求各位大神解答,
...全文
701 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
encoderlee 2017-07-08
  • 打赏
  • 举报
回复
mcfly29 2017-07-08
  • 打赏
  • 举报
回复
我的VS没有那个选项,是要安装更新包吗,装哪一个?还有请问大神VS打包安装程序怎么生成32位的安装包?
oyljerry 2017-07-07
  • 打赏
  • 举报
回复
vs编译的时候工程属性中有没有选择支持xp模式
赵4老师 2017-07-07
  • 打赏
  • 举报
回复
严格区分 Debug/Release 低版本/高版本 动态/静态 32位/64位 学会使用depends.exe查看exe依赖的dll

15,471

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 进程/线程/DLL
社区管理员
  • 进程/线程/DLL社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧