亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來(lái)到蟲(chóng)蟲(chóng)下載站! | ?? 資源下載 ?? 資源專(zhuān)輯 ?? 關(guān)于我們
? 蟲(chóng)蟲(chóng)下載站

?? usbhidiocdlg.cpp

?? 通過(guò)HID的控制來(lái)對(duì)usb進(jìn)行通訊
?? CPP
?? 第 1 頁(yè) / 共 3 頁(yè)
字號(hào):
		FILE_SHARE_READ|FILE_SHARE_WRITE,
		(LPSECURITY_ATTRIBUTES)NULL, 
		OPEN_EXISTING, 
		FILE_FLAG_OVERLAPPED, 
		NULL);

	DisplayLastError("CreateFile (ReadHandle): ");

	//Get an event object for the overlapped structure.

	/*API function: CreateEvent
	Requires:
	  Security attributes or Null
	  Manual reset (true). Use ResetEvent to set the event object's state to non-signaled.
	  Initial state (true = signaled) 
	  Event object name (optional)
	Returns: a handle to the event object
	*/

	if (hEventObject == 0)
	{
		hEventObject = CreateEvent 
			(NULL, 
			TRUE, 
			TRUE, 
			"");
	DisplayLastError("CreateEvent: ") ;

	//Set the members of the overlapped structure.

	HIDOverlapped.hEvent = hEventObject;
	HIDOverlapped.Offset = 0;
	HIDOverlapped.OffsetHigh = 0;
	}
}


void CUsbhidiocDlg::ReadAndWriteToDevice()
{
	//If necessary, find the device and learn its capabilities.
	//Then send a report and request a report.

	//Clear the List Box (optional).
	//m_ResultsList.ResetContent();

	DisplayData("***HID Test Report***");
	DisplayCurrentTime();

	//If the device hasn't been detected already, look for it.

	if (MyDeviceDetected==FALSE)
		{
		MyDeviceDetected=FindTheHID();
		}
	
	// Do nothing if the device isn't detected.

	if (MyDeviceDetected==TRUE)
		{
		switch (ReportType)
		{
			case 0:
				{
				// Output and Input Reports

				//Write a report to the device.

				WriteOutputReport();

				//Read a report from the device.

				ReadInputReport();	
			
				break;
				}
			case 1:
				{
				// Feature reports

				//Write a report to the device.

				WriteFeatureReport();

				//Read a report from the device.

				ReadFeatureReport();

				break;
				}

			default:
				{
				break;
				}
			}
		} // else
}


void CUsbhidiocDlg::ReadFeatureReport()
{
	
	// Read a Feature report from the device.

	CString	ByteToDisplay = "";
	BOOLEAN	Result;
	
	//The first byte is the report number.
	FeatureReport[0]=0;

	//Read a report from the device.

		/*
		HidD_GetFeature
		Returns:
		True on success
		Requires: 
		A device handle returned by CreateFile.
		A buffer to hold the report.
		The report length returned by HidP_GetCaps in Capabilities.InputReportByteLength.
		*/
		
		if (DeviceHandle != INVALID_HANDLE_VALUE)
			{
				Result = HidD_GetFeature
				(DeviceHandle,
				FeatureReport,
				Capabilities.FeatureReportByteLength);

				DisplayLastError("HidD_GetFeature: ");
			}
				
			if (!Result)
			{
				//The read attempt failed, so close the handles, display a message,
				//and set MyDeviceDetected to FALSE so the next attempt will look for the device.

				CloseHandles();
				DisplayData("Can't read from device");
				MyDeviceDetected = FALSE;
			}
			else
			{
				DisplayData("Received Feature report: ");
				
				DisplayFeatureReport();
			}
}


void CUsbhidiocDlg::ReadInputReport()
{

	// Retrieve an Input report from the device.

	CString	ByteToDisplay = "";

	DWORD	Result;
	
	//The first byte is the report number.
	InputReport[0]=0;

	// Find out if the "Use Control Transfers Only" check box is checked.

	UpdateData(true);

	if (m_UseControlTransfersOnly) 
	{

		//Read a report from the device using a control transfer.
	
		/*
		HidD_GetInputReport
		Returns:
		True on success
		Requires: 
		A device handle returned by CreateFile.
		A buffer to hold the report.
		The report length returned by HidP_GetCaps in Capabilities.InputReportByteLength.
		*/
		
		if (ReadHandle != INVALID_HANDLE_VALUE)
			{
			Result = HidD_GetInputReport
			(ReadHandle,
			InputReport,
			Capabilities.InputReportByteLength);

			DisplayLastError("HidD_GetInputReport: ");
			}
		else
			{
			Result = FALSE;
			}

		if (!Result)
			{
			//The read attempt failed, so close the handles, display a message,
			//and set MyDeviceDetected to FALSE so the next attempt will look for the device.

			CloseHandles();
			DisplayData("Can't read from device");
			MyDeviceDetected = FALSE;
			}
		else
			{
			DisplayData("Received Input report: ");
			
			//Display the report data.

			DisplayInputReport();
		
			/*
			USHORT	ByteNumber;
			CHAR	ReceivedByte;
		
			//Display the received data in the log and the Bytes Received List boxes.
			//Start at the top of the List Box.

			m_BytesReceived.ResetContent();
	
			//Step through the received bytes and display each.

			for (ByteNumber=0; ByteNumber < Capabilities.InputReportByteLength; ByteNumber++)
			{
				//Get a byte.

				ReceivedByte = InputReport[ByteNumber];

				//Display it.

				DisplayReceivedData(ReceivedByte);
			}
			*/
		}
	} 

	else
	{
 	
	/*API call:ReadFile
	'Returns: the report in InputReport.
	'Requires: a device handle returned by CreateFile
	'(for overlapped I/O, CreateFile must be called with FILE_FLAG_OVERLAPPED),
	'the Input report length in bytes returned by HidP_GetCaps,
	'and an overlapped structure whose hEvent member is set to an event object.
	*/

	if (ReadHandle != INVALID_HANDLE_VALUE)
		{
		Result = ReadFile 
		(ReadHandle, 
		InputReport, 
		Capabilities.InputReportByteLength, 
		&NumberOfBytesRead,
		(LPOVERLAPPED) &HIDOverlapped); 
		}
 
	DisplayLastError("ReadFile: ") ;

	/*API call:WaitForSingleObject
	'Used with overlapped ReadFile.
	'Returns when ReadFile has received the requested amount of data or on timeout.
	'Requires an event object created with CreateEvent
	'and a timeout value in milliseconds.
	*/

	Result = WaitForSingleObject 
		(hEventObject, 
		6000);

	DisplayLastError("WaitForSingleObject: ") ;
 
	switch (Result)
	{
	case WAIT_OBJECT_0:
		{
		DisplayData("Received Input report,");
					
		break;
		}
	case WAIT_TIMEOUT:
		{
		ValueToDisplay.Format("%s", "ReadFile timeout");
		DisplayData(ValueToDisplay);
		//Cancel the Read operation.

		/*API call: CancelIo
		Cancels the ReadFile
        Requires the device handle.
        Returns non-zero on success.
		*/
		
		Result = CancelIo(ReadHandle);
		
		//A timeout may mean that the device has been removed. 
		//Close the device handles and set MyDeviceDetected = False 
		//so the next access attempt will search for the device.
		CloseHandles();
		DisplayData("Can't read from device");
		MyDeviceDetected = FALSE;
		break;
		}
	default:
		{
		ValueToDisplay.Format("%s", "Undefined error");

		//Close the device handles and set MyDeviceDetected = False 
		//so the next access attempt will search for the device.

		CloseHandles();
		DisplayData("Can't read from device");
		MyDeviceDetected = FALSE;
		break;
		}
	}

	/*
	API call: ResetEvent
	Sets the event object to non-signaled.
	Requires a handle to the event object.
	Returns non-zero on success.
	*/

	ResetEvent(hEventObject);

	//Display the report data.

	DisplayInputReport();

	}
}


void CUsbhidiocDlg::RegisterForDeviceNotifications()
{

	// Request to receive messages when a device is attached or removed.
	// Also see WM_DEVICECHANGE in BEGIN_MESSAGE_MAP(CUsbhidiocDlg, CDialog).

	DEV_BROADCAST_DEVICEINTERFACE DevBroadcastDeviceInterface;
	HDEVNOTIFY DeviceNotificationHandle;

	DevBroadcastDeviceInterface.dbcc_size = sizeof(DevBroadcastDeviceInterface);
	DevBroadcastDeviceInterface.dbcc_devicetype = DBT_DEVTYP_DEVICEINTERFACE;
	DevBroadcastDeviceInterface.dbcc_classguid = HidGuid;

	DeviceNotificationHandle =
		RegisterDeviceNotification(m_hWnd, &DevBroadcastDeviceInterface, DEVICE_NOTIFY_WINDOW_HANDLE);

}


void CUsbhidiocDlg::ScrollToBottomOfListBox(USHORT Index)
{
	/* 
	Scroll to the bottom of the list box. 
	To do so, add a line and set it as the current selection,
	possibly scrolling the window.
	Then deselect the line, 
	leaving the list box scrolled to the bottom with nothing selected.
	*/

	m_ResultsList.SetCurSel( Index );
	m_ResultsList.SetCurSel( -1 );
}


void CUsbhidiocDlg::WriteFeatureReport()
{
	//Send a report to the device.

	DWORD	BytesWritten = 0;
	INT		Index =0;
	ULONG	Result;
	CString	strBytesWritten = "";

	//The first byte is the report number.

	FeatureReport[0]=0;

	//Can set the other report values here, or get them from the combo boxes.
	//OutputReport[1]=33;
	//OutputReport[2]=6;

	//Get the bytes to send from the combo boxes.
	
	//If Autoincrement is checked, increment the selection.

	if (m_cbutAutoIncrement.GetCheck()>0)
		{
		Index=m_cboByteToSend0.GetCurSel();
		Index=Index+1;
		m_cboByteToSend0.SetCurSel(Index);
		}

	if (m_cbutAutoIncrement.GetCheck()>0)
		{
		Index=m_cboByteToSend1.GetCurSel();
		Index=Index+1;
		m_cboByteToSend1.SetCurSel(Index);
		}

	//Get the values from the combo boxes.

	FeatureReport[1]=m_cboByteToSend0.GetCurSel();
	FeatureReport[2]=m_cboByteToSend1.GetCurSel();


	//The first byte is the report number.

	FeatureReport[0]=0;

	//Send a report to the device.

	/*
	HidD_SetFeature
	Sends a report to the device.
	Returns: success or failure.
	Requires:
	A device handle returned by CreateFile.
	A buffer that holds the report.
	The Output Report length returned by HidP_GetCaps,
	*/

	if (DeviceHandle != INVALID_HANDLE_VALUE)
		{
		Result = HidD_SetFeature
		(DeviceHandle,
		FeatureReport,
		Capabilities.FeatureReportByteLength);
	}

	DisplayLastError("HidD_SetFeature: ");

	if (!Result)
		{
		//The write attempt failed, so close the handles, display a message,
		//and set MyDeviceDetected to FALSE so the next attempt will look for the device.

		CloseHandles();
		DisplayData("Can't write to device");
		MyDeviceDetected = FALSE;
		}
	else
		{
		DisplayData("A Feature report was written to the device.");
		}

}


void CUsbhidiocDlg::WriteOutputReport()
{
	//Send a report to the device.

	DWORD	BytesWritten = 0;
	INT		Index =0;
	ULONG	Result;
	CString	strBytesWritten = "";

	UpdateData(true);

	//The first byte is the report number.

	OutputReport[0]=0;

	//Can set the other report values here, or get them from the combo boxes.
	//OutputReport[1]=33;
	//OutputReport[2]=6;

	//Get the bytes to send from the combo boxes.
	
	//If Autoincrement is checked, increment the selection.

	if (m_cbutAutoIncrement.GetCheck()>0)
		{
		Index=m_cboByteToSend0.GetCurSel();
		Index=Index+1;
		m_cboByteToSend0.SetCurSel(Index);
		}

	if (m_cbutAutoIncrement.GetCheck()>0)
		{
		Index=m_cboByteToSend1.GetCurSel();
		Index=Index+1;
		m_cboByteToSend1.SetCurSel(Index);
		}	

	//Get the values from the combo boxes.

	OutputReport[1]=m_cboByteToSend0.GetCurSel();
	OutputReport[2]=m_cboByteToSend1.GetCurSel();


	//The first byte is the report number.

	OutputReport[0]=0;

	if (m_UseControlTransfersOnly)
		{

		//Send a report to the device.

		/*
		HidD_SetOutputReport
		Sends a report to the device.
		Returns: success or failure.
		Requires:
		The device handle returned by CreateFile.
		A buffer that holds the report.
		The Output Report length returned by HidP_GetCaps,
		*/

		if (WriteHandle != INVALID_HANDLE_VALUE)
			{
			Result = HidD_SetOutputReport
			(WriteHandle,
			OutputReport,
			Capabilities.OutputReportByteLength);

			DisplayLastError("HidD_SetOutputReport: ");
			}

		if (Result)
			{
			DisplayData("An Output report was written to the device.");
			}
		else
			{
			//The write attempt failed, so close the handles, display a message,
			//and set MyDeviceDetected to FALSE so the next attempt will look for the device.

			CloseHandles();
			DisplayData("Can't write to device");
			MyDeviceDetected = FALSE;
			}

		}
	else
		{

		/*
		API Function: WriteFile
		Sends a report to the device.
		Returns: success or failure.
		Requires:
		A device handle returned by CreateFile.
		A buffer that holds the report.
		The Output Report length returned by HidP_GetCaps,
		A variable to hold the number of bytes written.
		*/

		if (WriteHandle != INVALID_HANDLE_VALUE)
			{
			Result = WriteFile 
			(WriteHandle, 
			OutputReport, 
			Capabilities.OutputReportByteLength, 
			&BytesWritten, 
			NULL);
		}

		//Display the result of the API call and the report bytes.

		DisplayLastError("WriteFile: ");

		if (!Result)
			{
			//The WriteFile failed, so close the handles, display a message,
			//and set MyDeviceDetected to FALSE so the next attempt will look for the device.

			CloseHandles();
			DisplayData("Can't write to device");
			MyDeviceDetected = FALSE;
			}
		else
			{
			DisplayData("An Output report was written to the device.");
			strBytesWritten.Format("%s%d", "Bytes Written: ", BytesWritten); 
			DisplayData(strBytesWritten);
			}
		}
}






?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产91在线|亚洲| 精品国免费一区二区三区| 一区二区久久久久| 91美女片黄在线| 亚洲精品成人精品456| 99视频一区二区| 亚洲欧洲日本在线| 欧美女孩性生活视频| 美女尤物国产一区| 国产欧美日韩在线观看| 国产成人在线视频网站| 国产精品色哟哟网站| 91丨porny丨首页| 日韩精品1区2区3区| 中文字幕久久午夜不卡| 色噜噜狠狠色综合中国| 日韩中文字幕区一区有砖一区 | 成人禁用看黄a在线| 天堂成人免费av电影一区| 久久久久久电影| 欧美无乱码久久久免费午夜一区| 国产一区在线视频| 国产片一区二区| 欧美一区二区三区在线电影| 豆国产96在线|亚洲| 免费看精品久久片| 亚洲午夜三级在线| 亚洲日本欧美天堂| 国产精品美女久久久久av爽李琼 | 蜜桃视频第一区免费观看| 18成人在线观看| 久久久美女毛片| 欧美成人性福生活免费看| 欧洲人成人精品| 91麻豆精品一区二区三区| 国产福利一区在线| 国产成人亚洲精品狼色在线| 免费成人美女在线观看.| 一区二区三区四区蜜桃| 成人免费视频在线观看| 国产精品久久精品日日| 国产欧美日韩另类一区| 国产欧美精品国产国产专区| 久久青草国产手机看片福利盒子| 欧美一区二区三区视频在线| 欧美肥妇bbw| 日韩欧美色综合网站| 欧美成人免费网站| 欧美韩国一区二区| 久久久久久9999| 国产婷婷色一区二区三区在线| 久久久国产午夜精品| 国产精品国产三级国产| 亚洲欧美日韩国产中文在线| 日韩电影在线观看网站| 男女男精品视频网| 成人国产精品视频| 欧美电影一区二区三区| 久久久91精品国产一区二区精品| 国产精品拍天天在线| 亚洲国产成人tv| 久久成人羞羞网站| 91小视频免费看| 欧美xxxxxxxx| 亚洲一区二区在线免费看| 激情综合色播激情啊| 色欲综合视频天天天| 欧美一二三四在线| 亚洲视频在线观看一区| 青青草国产成人99久久| 色婷婷国产精品久久包臀 | 国产欧美一区二区三区在线看蜜臀 | 欧美在线你懂得| 久久久精品tv| 老司机免费视频一区二区| 色一区在线观看| 国产视频一区二区在线观看| 午夜影视日本亚洲欧洲精品| 国产精品一二三| 日韩午夜在线观看视频| 一区二区成人在线视频| 粉嫩嫩av羞羞动漫久久久| 精品盗摄一区二区三区| 天天av天天翘天天综合网| 91精品福利在线| 亚洲啪啪综合av一区二区三区| 国产成人一级电影| 欧美电影精品一区二区| 久久精品国产77777蜜臀| 91精品免费在线观看| 石原莉奈在线亚洲二区| 91成人看片片| 亚洲国产精品久久久久婷婷884 | 精品影院一区二区久久久| 欧美成人video| 国产呦精品一区二区三区网站| 久久综合九色综合97婷婷| 激情亚洲综合在线| 国产视频亚洲色图| 一本一本大道香蕉久在线精品 | 亚洲线精品一区二区三区| 欧美三级一区二区| 蜜臀av性久久久久蜜臀aⅴ| 精品国免费一区二区三区| 国产成人精品影视| 一区二区三区四区国产精品| 欧美影院一区二区三区| 美国十次了思思久久精品导航| 精品乱人伦一区二区三区| 国产成人精品1024| 亚洲一区二区三区在线看| 26uuu国产电影一区二区| 99亚偷拍自图区亚洲| 日韩电影在线免费观看| 中文文精品字幕一区二区| 欧美日韩免费观看一区二区三区| 蜜臀av国产精品久久久久| 国产精品久久久久婷婷二区次| 欧美人狂配大交3d怪物一区| 国产91在线|亚洲| 奇米精品一区二区三区四区| 中文av字幕一区| 亚洲精品一区二区三区精华液| 欧美羞羞免费网站| 99久久久精品免费观看国产蜜| 久久99国产乱子伦精品免费| 亚洲一级二级在线| 国产精品久久777777| 欧美精品一区二区三区视频| 欧美三级视频在线播放| 9色porny自拍视频一区二区| 国产在线精品免费| 美国毛片一区二区三区| 午夜精品视频在线观看| 亚洲裸体在线观看| 亚洲人成在线播放网站岛国| 国产精品五月天| 亚洲色图欧洲色图| 一色屋精品亚洲香蕉网站| 中文字幕视频一区| 国产欧美日韩激情| 日韩视频在线观看一区二区| 欧美三级日韩三级| 91国偷自产一区二区使用方法| 成人精品一区二区三区四区| 懂色av中文字幕一区二区三区 | 亚洲国产欧美日韩另类综合| 亚洲精品乱码久久久久| 亚洲精品乱码久久久久久| 夜夜嗨av一区二区三区网页 | 亚洲国产激情av| 中文字幕一区二区不卡| 一区二区三区在线视频观看58| 一区二区三区免费观看| 婷婷夜色潮精品综合在线| 激情文学综合网| 在线观看不卡一区| 日韩欧美一区电影| 中文字幕亚洲一区二区va在线| 亚洲男人天堂一区| 激情五月婷婷综合| 91免费观看国产| 日韩欧美美女一区二区三区| 亚洲国产精品精华液2区45| 亚洲高清免费在线| 国产米奇在线777精品观看| 色综合天天综合网天天狠天天| 91精品国产品国语在线不卡| 一区在线播放视频| 精品无人码麻豆乱码1区2区 | 国产欧美一区二区三区沐欲| 日韩精品每日更新| 日本久久精品电影| 国产欧美精品区一区二区三区 | 99在线热播精品免费| 久久久久国产成人精品亚洲午夜| 樱花影视一区二区| 国产高清亚洲一区| 日韩精品一区二区三区四区视频 | 亚洲国产精华液网站w| 韩国一区二区三区| 日韩网站在线看片你懂的| 亚洲韩国一区二区三区| www.亚洲在线| 国产精品久久久久aaaa樱花| 国产精品一二三| 国产色综合一区| 国产白丝精品91爽爽久久| 精品国产免费一区二区三区香蕉| 日韩电影一区二区三区四区| 欧美日韩成人一区| 日韩精品乱码免费| 欧美一区二区三区视频在线观看| 午夜精品久久久久久久99水蜜桃| 欧美午夜不卡视频| 日韩av网站在线观看| 久久久亚洲精品石原莉奈| 国产在线观看一区二区| 久久精品日产第一区二区三区高清版| 久久av中文字幕片|