C++ DoModal返回-1 Getlasterror表示句柄无效
我正在使用Win32应用程序,在这个DoModal函数中返回-1,GetlastError()返回6(无效句柄)。我尝试删除GDI句柄以修复GDI排气,结果失败 其他信息: 我使用的是Visual Studio 2012,此应用程序适用于Compact 2013C++ DoModal返回-1 Getlasterror表示句柄无效,c++,visual-studio-2012,mfc,dialog,windows-ce,C++,Visual Studio 2012,Mfc,Dialog,Windows Ce,我正在使用Win32应用程序,在这个DoModal函数中返回-1,GetlastError()返回6(无效句柄)。我尝试删除GDI句柄以修复GDI排气,结果失败 其他信息: 我使用的是Visual Studio 2012,此应用程序适用于Compact 2013 if(!bDeviceOpened) { bDeviceOpened=OpenDriver(); if(bDeviceOpened == 0) { AfxMessageBox(_T("Please ma
if(!bDeviceOpened)
{
bDeviceOpened=OpenDriver();
if(bDeviceOpened == 0)
{
AfxMessageBox(_T("Please make sure the driver is up and runnning"));
return FALSE;
}
}
//Reading the Driver version
DWORD nBytesReturned = 0;
if(!GetOID(OID_RPS_DRIVER_STATS, &stats, sizeof(stats), &nBytesReturned) )
{
AfxMessageBox(_T("Failed to query the stats"));
}
m_pMainWnd = &dlg;
int nResponse = dlg.DoModal();
if (nResponse == IDOK)
{
// TODO: Place code here to handle when the dialog is
// dismissed with OK
}
else if (nResponse == IDCANCEL)
{
// TODO: Place code here to handle when the dialog is
// dismissed with Cancel
}
为什么不获取对话框?DoModal()在资源未正确映射到对话框时返回-1。如果您进入DoModal(),您将发现
//如果加载对话框模板资源失败,返回-1
我建议您调用AfxSetResourceHandle()DoModal()之前的函数你能调用“CommDlgExtendedError()”吗?现在CommDlgExtendedError()和GetLastError()返回0,DoModal仍然是-1不使用GetLastError(),当DoModal()返回-1时,它不会告诉你任何可靠的信息。返回代码只是意味着无法创建对话框,请使用调试器找出原因。单步执行代码。@SurendranT尝试注释/读取驱动程序版本DWORD NBytesReturn=0;如果(!GetOID(OID_RPS_DRIVER_STATS,&STATS,sizeof(STATS),&nbytesreturn)){AfxMessageBox(_T(“未能查询统计数据”);}”