请vc的高手帮帮忙,我的程序遇到的问题,希望大家能给些意见及帮助
void Csearch::SetupDriverComboBox() {CString sDriverName, sCompleteName;
char num[3] = {0,0,0};
HANDLE hDriver;
CComboBox* pCBox = GetCComboBox(); // inline defined in BulkXFERDlg.h
pCBox->ResetContent ();
// Assume 32 EZ-USB boards are attached to the PC.
// Try to open each driver. If successful, add driver name to combobox
for (int i = 0; i < MAX_USB_DEV_NUMBER; i++)
{
_itoa( i, num, 10 );
sDriverName = (CString)"Ezusb-" + num;
if (OpenDriver(&hDriver, sDriverName))
{
char a2[10];
sprintf(a2, "%ld", (long) hDriver);
MessageBox(a2);
//MessageBox("test before");
pCBox->AddString ((LPCTSTR) sDriverName);
}
else
{
if (i==0)
{
AfxMessageBox("No EZ-USB device drivers were found. Perhaps no device is connected", MB_OK|MB_ICONSTOP);
exit(0);
}
}
}
pCBox->SetCurSel(0);
}
BOOLEAN Csearch::OpenDriver (HANDLE* phDriver, CString devname)
{
SECURITY_ATTRIBUTES security;
security.nLength = sizeof(security);
security.lpSecurityDescriptor = NULL;
security.bInheritHandle = false;
CString completeDeviceName = (CString)"\\\\.\\" + devname;
*phDriver = CreateFile( completeDeviceName,
GENERIC_WRITE,
FILE_SHARE_WRITE,
&security,
OPEN_EXISTING,
0,
NULL);
return (*phDriver != INVALID_HANDLE_VALUE);
}
调用 SetupDriverComboBox();函数,编译没有问题,但是运行时却提示终止 发送 不发送的错误,望大家能帮帮忙 解决解决这个问题,先谢谢各位了