如题。是在APP,VIEW ,还是DIALOG里呢?

解决方案 »

  1.   

    是这样的,我有一个硬件,有驱动,提供了VB的DLL,我已经找到方法把它用在VC中了。下面是代码: 
    HRESULT hresult; 
    CLSID clsid; CoInitialize(NULL); //initialize COM library 
    hresult=CLSIDFromProgID(OLESTR("T24DataProviderCOM.DataProvider"), &clsid);    //retrieve CLSID of component 
    if(FAILED(hresult)) 

    ::AfxMessageBox(L"ProgID"); 

    _DataProvider *t; 
    hresult=CoCreateInstance(clsid,NULL,CLSCTX_INPROC_SERVER,__uuidof(_DataProvider),(LPVOID *) &t); 
    if(FAILED(hresult)) 

    ::AfxMessageBox(L"失败",MB_OKCANCEL, 0); 
    return; 
    } 通过 t  可以得到里面所有的函数了。 
    这部分代码我是不是应该放在构造函数里呢?还有通过上面的代码我是不是就已经连接上这个USB设备了呢? 这个t是不是这个设备的一个实例呢?搞不懂哈。请教大家了。反正很迷惑。 现在我把代码放在一个CButton的响应函数里,在USB设备没有接电源的时候,程序可以正常运行,但是一接通电源,程序就出现段错误,是哪里的问题呢?
    出现的错误提示:Unhandled exception at 0x1dfe4061 in T24DPCOMExample.exe: 0xC0000005: Access violation writing location 0xffdeaf48.
    好像是一个错误没有被捕获?我非常着急,请及时回答,谢谢你!
      

  2.   

    在void __cdecl _free_base (void * pBlock)里面的
    这里:#endif  /* _WIN64 */
            {
                retval = HeapFree(_crtheap, 0, pBlock);
                if (retval == 0)
                {
                    errno = _get_errno_from_oserr(GetLastError());
                }
            }出现Unhandled exception at 0x1dfe4061 in T24DPCOMExample.exe: 0xC0000005: Access violation writing location 0xffdeaf48. 
    错误