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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? usbhidiocdlg.cpp

?? 真正完整
?? CPP
?? 第 1 頁 / 共 3 頁
字號:
		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;
		if(Index > 0xff) 
			Index = 0;
		m_cboByteToSend0.SetCurSel(Index);
		}

	if (m_cbutAutoIncrement.GetCheck()>0)
		{
		Index=m_cboByteToSend1.GetCurSel();
		Index=Index+1;
		if(Index > 255)
			Index = 0;
		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);
			}
		}
}






?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美艳星brazzers| 亚洲欧美怡红院| 欧美少妇一区二区| 色综合视频在线观看| 石原莉奈在线亚洲二区| 久99久精品视频免费观看| 久久蜜桃av一区精品变态类天堂| 蜜臀av一区二区在线免费观看| 精品少妇一区二区三区日产乱码 | 色婷婷综合久久久| 亚洲黄色录像片| 欧美综合视频在线观看| 亚洲综合视频在线| 91麻豆精品国产无毒不卡在线观看| 亚洲电影一级黄| 欧美一级片在线看| 国内精品久久久久影院薰衣草| 久久精品视频一区二区三区| 成人av在线网站| 亚洲自拍偷拍麻豆| 成人综合在线观看| 成人永久看片免费视频天堂| 色成人在线视频| 日韩一区二区在线观看视频| 欧美美女一区二区三区| 成人免费的视频| 欧美日韩精品综合在线| 亚洲少妇最新在线视频| 免费视频最近日韩| 久久精品免视看| 成人av在线网| 日本亚洲免费观看| 精品成人一区二区| 亚洲综合网站在线观看| 国产成人8x视频一区二区| 中文字幕精品一区二区三区精品| 岛国精品在线观看| 首页亚洲欧美制服丝腿| 久久亚洲欧美国产精品乐播| 99久久婷婷国产精品综合| 亚洲午夜免费福利视频| 日本一区二区免费在线| 欧美三级三级三级| 99久久国产综合精品女不卡| 日韩精品欧美精品| 一区二区成人在线视频| 久久久综合激的五月天| 欧美精品粉嫩高潮一区二区| 不卡影院免费观看| 精品亚洲aⅴ乱码一区二区三区| 成人免费一区二区三区在线观看| 欧洲一区在线观看| 久久久天堂av| 99视频热这里只有精品免费| 一区二区三区波多野结衣在线观看| 久久国产乱子精品免费女| 色天天综合久久久久综合片| 玉足女爽爽91| 美女任你摸久久| 欧美xxx久久| 制服.丝袜.亚洲.另类.中文| 日韩一区二区免费在线观看| 精品国精品自拍自在线| 久久嫩草精品久久久精品| 久久影院午夜片一区| 欧美高清在线精品一区| 亚洲九九爱视频| 天堂一区二区在线| 精品亚洲成a人在线观看 | 一区二区免费在线| 午夜影院久久久| 精品一区二区在线播放| 成人午夜精品一区二区三区| 色一情一乱一乱一91av| 777欧美精品| 久久综合给合久久狠狠狠97色69| 中文字幕久久午夜不卡| 亚洲图片欧美综合| 国产一区二区三区日韩| 91亚洲精品久久久蜜桃网站 | 国产尤物一区二区| 99re热视频这里只精品| 欧美精品自拍偷拍动漫精品| 久久亚洲精品小早川怜子| 亚洲欧美日韩国产综合| 日本强好片久久久久久aaa| 成人免费高清视频在线观看| 欧美午夜在线一二页| 久久久无码精品亚洲日韩按摩| 亚洲综合激情网| 韩国三级在线一区| 欧美最新大片在线看| 国产欧美视频一区二区三区| 亚洲一区二区精品视频| 国产乱码精品1区2区3区| 欧美色视频在线观看| 国产欧美综合在线观看第十页| 亚洲一区二区三区小说| 国产成人综合视频| 欧美美女网站色| 亚洲天堂成人在线观看| 久久91精品久久久久久秒播| 在线观看欧美精品| 国产香蕉久久精品综合网| 天天爽夜夜爽夜夜爽精品视频| 成人激情免费电影网址| 欧美大片在线观看一区| 亚洲综合色区另类av| 成人小视频在线| 欧美岛国在线观看| 日韩va欧美va亚洲va久久| 日本精品视频一区二区三区| 中文字幕欧美日韩一区| 久久99精品国产91久久来源| 欧美剧情片在线观看| 亚洲色图清纯唯美| 不卡电影一区二区三区| 国产亚洲欧美激情| 美美哒免费高清在线观看视频一区二区| 色系网站成人免费| 国产精品热久久久久夜色精品三区| 久久er精品视频| 欧美一区二区免费视频| 亚洲va天堂va国产va久| 在线观看不卡视频| 亚洲欧美日韩久久| 色综合天天综合色综合av| 中文字幕av在线一区二区三区| 韩国精品主播一区二区在线观看| 7777精品伊人久久久大香线蕉经典版下载 | 久久色.com| 男人的天堂久久精品| 91精品国产入口| 日日摸夜夜添夜夜添亚洲女人| 欧美色偷偷大香| 午夜亚洲国产au精品一区二区| 欧美在线视频你懂得| 亚洲精品自拍动漫在线| 色妞www精品视频| 亚洲精品国产成人久久av盗摄| 99免费精品视频| 中文字幕一区在线观看视频| 成人av在线看| 亚洲欧美另类图片小说| 91成人在线免费观看| 亚洲18影院在线观看| 欧美日韩一卡二卡三卡| 亚洲va中文字幕| 欧美一级二级三级乱码| 美国十次综合导航| 久久久五月婷婷| 成人av综合一区| 亚洲欧美日韩中文字幕一区二区三区| 99久久国产综合精品色伊| 亚洲丝袜美腿综合| 欧美在线短视频| 蜜臀久久99精品久久久久久9| 精品少妇一区二区三区| 国产99一区视频免费| 亚洲欧洲韩国日本视频| 91国偷自产一区二区使用方法| 亚洲www啪成人一区二区麻豆| 日韩一区二区三区视频| 国产一区二区三区在线观看免费视频 | 成人久久视频在线观看| 综合色天天鬼久久鬼色| 欧美日韩一级片在线观看| 轻轻草成人在线| 国产欧美一区二区精品性色| 一本一道久久a久久精品 | 成a人片国产精品| 亚洲成人综合视频| 久久一区二区视频| 91麻豆swag| 免费观看日韩av| 国产精品午夜久久| 欧美日韩一级二级三级| 麻豆精品国产91久久久久久| 国产亚洲一二三区| 在线精品视频一区二区三四| 精品一区二区精品| 有码一区二区三区| 2023国产精品| 色吧成人激情小说| 麻豆成人在线观看| 亚洲色图.com| 日韩欧美www| 色噜噜偷拍精品综合在线| 久久精品国产999大香线蕉| 最近日韩中文字幕| 2021国产精品久久精品| 欧美日精品一区视频| 国产大片一区二区| 天天av天天翘天天综合网色鬼国产| 国产欧美综合色| 日韩久久免费av| 欧美性三三影院| 99久久夜色精品国产网站| 麻豆免费看一区二区三区| 一区二区三区色|