2 qq 29444093 qq_29444093 于 2016.04.13 22:54 提问

WriteFile失败,GetLastError返回1,功能错误,求大神解答啊

向DSP写入数据,设备打开成功句柄有效,WriteFile失败,GetLastError返回1
部分代码:

    DWORD dwTransRet = 0, dwRecRet = 0;
    BOOL bTransRet, bRecRet;
    DWORD dwError;
    unsigned char RecBuff[BufferSize] = { 0 };
    unsigned char TransBuff[BufferSize] = { 'a','b','c','d','e' };

    BOOL isDeviceOpen = DeviceOpen(devicehandle, vID, pID);
    if (isDeviceOpen == TRUE)
    {
        //数据传输测试
        while (1)
        {
            bTransRet = WriteFile(devicehandle, TransBuff, BufferSize, &dwTransRet, NULL);
            if (bTransRet == 0) dwError = GetLastError();
            bRecRet = ReadFile(devicehandle, RecBuff, BufferSize, &dwRecRet, NULL);
            if (bRecRet == 0) dwError = GetLastError();
        }
    }

2个回答

devmiao
devmiao   Ds   Rxr 2016.04.13 23:56

看下是不是端口权限的问题呢

qq_29444093
qq_29444093 权限问题应该错误代码是5吧? 另外怎么查看端口权限?
一年多之前 回复
qq_29444093
qq_29444093   2016.04.18 14:23

求大神指导啊 问题还没解决

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!