写64字节以下可以,超过64字节就返回121L(0x79)的错误.
查看该错误的定义,如下:
"#define ERROR_SEM_TIMEOUT 121L"
操作代码如下:
BOOL CIOCtrlHelper::CDBWriteData(HANDLE hDevice, BYTE *pDataBuffer, long nBufLen)
{
ULONG returned,length;
DWORD dwErrCode;
BOOL status;
ASSERT(pDataBuffer);
SCSI_PASS_THROUGH_DIRECT_WITH_BUFFER sptdwb;
ZeroMemory(&sptdwb,sizeof(SCSI_PASS_THROUGH_DIRECT_WITH_BUFFER));
sptdwb.sptd.Length = sizeof(SCSI_PASS_THROUGH_DIRECT);
sptdwb.sptd.PathId = 0;
sptdwb.sptd.TargetId = 1;
sptdwb.sptd.Lun = 0;
sptdwb.sptd.CdbLength = IOCTRL_CDB_LEN;
sptdwb.sptd.SenseInfoLength = 14;
sptdwb.sptd.DataIn = SCSI_IOCTL_DATA_OUT;
sptdwb.sptd.DataTransferLength = nBufLen;
sptdwb.sptd.TimeOutValue = IOCTRL_TIMEOUT_VALUE;
sptdwb.sptd.DataBuffer = pDataBuffer;
sptdwb.sptd.SenseInfoOffset =
offsetof(SCSI_PASS_THROUGH_WITH_BUFFERS,SenseBuf);
memcpy( sptdwb.sptd.Cdb, m_byCDBBuffer, IOCTRL_CDB_LEN );
length = sizeof(SCSI_PASS_THROUGH_DIRECT_WITH_BUFFER);
status = DeviceIoControl(hDevice,
IOCTL_SCSI_PASS_THROUGH_DIRECT,
&sptdwb,
length,
&sptdwb,
length,
&returned,
NULL);
dwErrCode = GetLastError();
if( dwErrCode == 0x79 ) // Timeout
{
}
if( !status )
return FALSE;
else
return TRUE;
}
|