| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 435 人关注过本帖
标题:请vc的高手帮帮忙,我的程序遇到的问题,希望大家能给些意见及帮助
取消只看楼主 加入收藏
blairlu1987
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2012-7-12
收藏
 问题点数:0 回复次数:0 
请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();函数,编译没有问题,但是运行时却提示终止 发送 不发送的错误,望大家能帮帮忙 解决解决这个问题,先谢谢各位了
搜索更多相关主题的帖子: 希望 successful 
2012-07-12 20:23
快速回复:请vc的高手帮帮忙,我的程序遇到的问题,希望大家能给些意见及帮助
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.016163 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved