//打開 USB 口讀寫, 由驅(qū)動(dòng)程序的 Pipe 名確定
HANDLE hPipe = OpenMyDevPipe("MyPipe1") //驅(qū)動(dòng)程序里面的 Pipe 名, 對(duì)應(yīng)訪問某個(gè)端點(diǎn)的 I/O, 這里我亂寫的, 需要與驅(qū)動(dòng)一致
if(hPipe != INVALID_HANDLE_VALUE) //打開 Pipe 成功
{
ReadFile(hPipe, Buffer, BufSize, &nBytesRead, NULL) //從 hPipe 里讀取數(shù)據(jù)到 Buffer 里
//WriteFile(hPipe, Buffer, BytesToWrite, &nBytesWritten, NULL) //把 Buffer 里面的 BytesToWrite 字節(jié)寫入 hPipe
CloseHandle(hPipe)
}
//使用 DeviceIoControl 訪問 USB 設(shè)備
HANDLE hDevice = OpenMyDevice()
if(hDevice != INVALID_HANDLE_VALUE) //打開設(shè)備成功
{
//這些 DeviceIoControl 功能都是由設(shè)備定義的, 具體看設(shè)備和驅(qū)動(dòng)的資料
if(DeviceIoControl(hDevice, IOCTL_READ_xxxx, &IOBlock, sizeof(IOBLOCK), &c, 1, &nBytes, NULL))
{
//成功
}
CloseHandle(hDevice)
}
標(biāo)簽:
Pipe
OpenMyDevPipe
MyPipe1
HANDLE
上傳時(shí)間:
2014-11-25
上傳用戶:stampede