about USBview(IOCTL_USB_GET_NODE_INFORMATION) |
尚未結案
|
jorping
一般會員 發表:3 回覆:5 積分:1 註冊:2006-11-15 發送簡訊給我 |
USBVIEWDEVICEIOCONTROLIOCTL_USB_GET_NODE_INFORMATIONFALSECODE 謝謝!
void TForm1::ShowInformation(String str) } { //TODO: Add your source code here char strShow[64]; String ShowInfo; char HCName[16]; int HCNum; HANDLE hHCDev; PCHAR rootHubName; PCHAR leafName; ULONG index; bool success; PUSB_NODE_CONNECTION_INFORMATION connectionInfo; HANDLE hHubDevice; PCHAR driverKeyName ,deviceDesc; ULONG nBytes; PUSB_NODE_INFORMATION HubInfo; PCHAR deviceName = NULL; int port; for(HCNum = 0;HCNum < NUM_HCS_TO_CHECK;HCNum ) { wsprintf(HCName,"\\\\.\\HCD%d",HCNum); hHCDev = CreateFile(HCName, GENERIC_WRITE, 找到控制器錯誤控制器控制器名稱: ShowInformation("!\r\n"); goto end; } wsprintf(strShow,"USB:%s",rootHubName); ShowInfo = strShow; ShowInformation(ShowInfo); HubInfo = (PUSB_NODE_INFORMATION)malloc strcpy(deviceName sizeof("\\\\.\\")-1,rootHubName); hHubDevice = CreateFile(deviceName, GENERIC_WRITE, FILE_SHARE_WRITE, ShowInformation(""); goto end; } success = DeviceIoControl(hHubDevice, IOCTL_USB_GET_NODE_INFORMATION, HubInfo, sizeof(USB_NODE_INFORMATION), //false,VCTRUE錯誤!結束 port = HubInfo->u.HubInformation.HubDescriptor.bNumberOfPorts; for(index = 1;index <= port;index ) { ULONG nBytes; 錯誤! free(connectionInfo); ShowInformation(""); goto end; } if(connectionInfo) { if(connectionInfo->ConnectionStatus == DeviceConnected) { wsprintf(strShow,"%dusb.",index); 第埠沒有設備連接結束 }//for-indexend: //PCHAR TForm1::GetHCDDriverKeyName(HANDLE HCD) &nBytes, NULL); if(!success) { goto GetHCDDriverKeyNameError; } driverKeyNameA = WideStrToMultiStr(driverKeyNameW->DriverKeyName ); free(driverKeyNameW); return driverKeyNameA; GetHCDDriverKeyNameError: if (driverKeyNameW != NULL) { 出錯} 資料處理函數 { //TODO: Add your source code here ULONG nBytes; PCHAR MultiStr; nBytes = WideCharToMultiByte( CP_ACP, 0, WideStr, -1, NULL, 0, 0, WideStr, -1, MultiStr, nBytes, NULL, NULL); if (nBytes == 0) { free(MultiStr); return NULL; } return MultiStr; //PCHAR TForm1::GetRootHubName(HANDLE HostController) rootHubNameA; rootHubNameW = NULL; rootHubNameA =NULL; success = DeviceIoControl(HostController, IOCTL_USB_GET_ROOT_HUB_NAME, 0, 0, &rootHubName, sizeof(rootHubName), &nBytes, NULL); if(!success) { goto GetRootHubNameError; } nBytes = rootHubName.ActualLength; rootHubNameW = (PUSB_ROOT_HUB_NAME)malloc(nBytes); success = false; success = DeviceIoControl(HostController, IOCTL_USB_GET_ROOT_HUB_NAME, NULL, 0, GetRootHubNameError: if (rootHubNameW != NULL) { free(rootHubNameW); rootHubNameW = NULL; ShowInformation("!\r\n"); } return NULL; }
------
Jordan.Jeng 編輯記錄
dllee 重新編輯於 2007-04-19 23:55:03, 註解 如果是提問,請記得將文章分類設為 [問題] 喔,謝謝您的配合。‧
|
stnovel
一般會員 發表:4 回覆:4 積分:1 註冊:2007-01-10 發送簡訊給我 |
PUSB_NODE_INFORMATION HubInfo;
不是這樣宣告,改成 PUSBDEVICEINFO info; info = NULL; info = (PUSBDEVICEINFO) alloca(sizeof(USBDEVICEINFO)); info->HubInfo = (PUSB_NODE_INFORMATION)alloca(sizeof(USB_NODE_INFORMATION)); 然後這樣就可 // Root hub is open. Collect the node information Success = DeviceIoControl(RootHubHandle, IOCTL_USB_GET_NODE_INFORMATION, info->HubInfo, sizeof(USB_NODE_INFORMATION), info->HubInfo, sizeof(USB_NODE_INFORMATION), &BytesReturned, NULL); if (!Success) return GetLastError(); |
hap0702
一般會員 發表:0 回覆:5 積分:1 註冊:2007-04-04 發送簡訊給我 |
各位大大:
能否將source code寄給我參考作範例 謝謝 ===================引 用 文 章=================== PUSB_NODE_INFORMATION HubInfo; 不是這樣宣告,改成 PUSBDEVICEINFO info; info = NULL; info = (PUSBDEVICEINFO) alloca(sizeof(USBDEVICEINFO)); info->HubInfo = (PUSB_NODE_INFORMATION)alloca(sizeof(USB_NODE_INFORMATION)); 然後這樣就可 // Root hub is open. Collect the node information Success = DeviceIoControl(RootHubHandle, IOCTL_USB_GET_NODE_INFORMATION, info->HubInfo, sizeof(USB_NODE_INFORMATION), info->HubInfo, sizeof(USB_NODE_INFORMATION), &BytesReturned, NULL); if (!Success) return GetLastError(); |
stnovel
一般會員 發表:4 回覆:4 積分:1 註冊:2007-01-10 發送簡訊給我 |
Please see this
http://delphi.ktop.com.tw/board.php?cid=31&fid=79&tid=87849 |
hap0702
一般會員 發表:0 回覆:5 積分:1 註冊:2007-04-04 發送簡訊給我 |
您好
感謝回覆 ===================引 用 文 章=================== Please see this http://delphi.ktop.com.tw/board.php?cid=31&fid=79&tid=87849 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |