Hi,

I followed DDK sample SPTI to derive the following code piece to access a
USB dongle (a Mass Storage Device) I'm developing. When the piece code is in
a Win32 console program it works fine. It can send out commands through IOCTL
+ SCSI_PASS_THROUGH and get results back. But after I put it into a MFC GUI
program it stop working. The error code I get from GetLastError is 0x32 ->
ERROR_NOT_SUPPORTED. Can anyone give me a hint?

Thanks,

Ken

code is at the following:
--------------------------------------------------------------------------------
fileHandle = CreateFile(devicename,
GENERIC_READ|GENERIC_WRITE,
FILE_SHARE_READ|FILE_SHARE_WRITE,
NULL,
OPEN_EXISTING,
0,
NULL);

if (fileHandle == INVALID_HANDLE_VALUE) {
return FALSE;
}

ZeroMemory(&sptwb,sizeof(SCSI_PASS_THROUGH_WITH_BUFFERS));

sptwb.spt.Length = sizeof(SCSI_PASS_THROUGH);
sptwb.spt.PathId = 0;
sptwb.spt.TargetId = 1;
sptwb.spt.Lun = 0;
sptwb.spt.CdbLength = CDB6GENERIC_LENGTH;
sptwb.spt.SenseInfoLength = 24;
sptwb.spt.DataIn = SCSI_IOCTL_DATA_IN;
sptwb.spt.DataTransferLength = 36;
sptwb.spt.TimeOutValue = 4;
sptwb.spt.DataBufferOffset =
offsetof(SCSI_PASS_THROUGH_WITH_BUFFERS,ucDataBuf) ;
sptwb.spt.SenseInfoOffset =
offsetof(SCSI_PASS_THROUGH_WITH_BUFFERS,ucSenseBuf );
sptwb.spt.Cdb[0] = SCSIOP_INQUIRY;
sptwb.spt.Cdb[1] = 0xff;
sptwb.spt.Cdb[2] = 0x00;
sptwb.spt.Cdb[4] = 0x10;
length = offsetof(SCSI_PASS_THROUGH_WITH_BUFFERS,ucDataBuf) +
sptwb.spt.DataTransferLength;

status = DeviceIoControl(fileHandle,
IOCTL_SCSI_PASS_THROUGH,
&sptwb,
sizeof(SCSI_PASS_THROUGH),
&sptwb,
length,
&returned,
FALSE);


if (!status)
{
DWORD dw = GetLastError();
CloseHandle(fileHandle);
return FALSE;
}
CloseHandle(fileHandle);
return TRUE;