|
这个是可以做到的
BOOL CHubHelper::Hub_PlugOff(LPCTSTR hubName, DWORD PortIndex)
{
BOOL Success(FALSE);
SECURITY_ATTRIBUTES SA={0};
SA.nLength = sizeof(SECURITY_ATTRIBUTES);
HANDLE HubHandle = CreateFile(hubName, GENERIC_WRITE, FILE_SHARE_WRITE, &SA, OPEN_EXISTING, 0, NULL);
if( HubHandle != INVALID_HANDLE_VALUE )
{
DWORD BytesReturned = 0;
ULONG ConnectedHub = PortIndex;
Success = DeviceIoControl(HubHandle, IOCTL_USB_HUB_CYCLE_PORT, &ConnectedHub,sizeof(ConnectedHub), &ConnectedHub, sizeof(ConnectedHub), &BytesReturned, NULL);
CloseHandle(HubHandle);
}
return Success;
} |
|