//打開 USB 口讀寫, 由驅動程序的 pipe 名確定
HANDLE hpipe = OpenMyDevpipe("Mypipe1") //驅動程序里面的 pipe 名, 對應訪問某個端點的 I/O, 這里我亂寫的, 需要與驅動一致
if(hpipe != INVALID_HANDLE_VALUE) //打開 pipe 成功
{
ReadFile(hpipe, Buffer, BufSize, &nBytesRead, NULL) //從 hpipe 里讀取數據到 Buffer 里
//WriteFile(hpipe, Buffer, BytesToWrite, &nBytesWritten, NULL) //把 Buffer 里面的 BytesToWrite 字節寫入 hpipe
CloseHandle(hpipe)
}
//使用 DeviceIoControl 訪問 USB 設備
HANDLE hDevice = OpenMyDevice()
if(hDevice != INVALID_HANDLE_VALUE) //打開設備成功
{
//這些 DeviceIoControl 功能都是由設備定義的, 具體看設備和驅動的資料
if(DeviceIoControl(hDevice, IOCTL_READ_xxxx, &IOBlock, sizeof(IOBLOCK), &c, 1, &nBytes, NULL))
{
//成功
}
CloseHandle(hDevice)
}
標簽:
pipe
OpenMyDevpipe
Mypipe1
HANDLE
上傳時間:
2014-11-25
上傳用戶:stampede