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

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

?? usbhidiocdlg.cpp

?? USB( HID ) sample code for VC+++6.0
?? CPP
?? 第 1 頁 / 共 3 頁
字號:
		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);
			}
		}
}






?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
婷婷一区二区三区| 日本高清免费不卡视频| 91视频在线观看免费| 欧美无乱码久久久免费午夜一区 | 麻豆91免费观看| 成人精品国产福利| 欧美成人猛片aaaaaaa| 亚洲午夜精品在线| 99视频热这里只有精品免费| 日韩精品自拍偷拍| 亚洲午夜久久久久中文字幕久| jlzzjlzz欧美大全| www国产精品av| 日本视频中文字幕一区二区三区| 91欧美一区二区| 欧美极品美女视频| 国产精品99久| 久久久精品国产免大香伊| 日韩电影在线一区| 777亚洲妇女| 天堂va蜜桃一区二区三区| 在线亚洲人成电影网站色www| 国产精品欧美综合在线| 成人免费电影视频| 中文字幕精品一区| 成人在线一区二区三区| 国产亚洲va综合人人澡精品| 国产一区二区福利| 久久免费国产精品| 国产精品影视天天线| 亚洲精品一区二区三区蜜桃下载| 美女精品一区二区| 精品国免费一区二区三区| 久久黄色级2电影| 精品国产三级电影在线观看| 黄网站免费久久| 久久精品视频在线看| 国产成人精品www牛牛影视| 国产日产欧美一区| 91丨porny丨首页| 亚洲精品乱码久久久久久久久 | 午夜欧美大尺度福利影院在线看| 91国偷自产一区二区三区成为亚洲经典 | 中文字幕在线一区| 97精品国产露脸对白| 亚洲人成在线播放网站岛国| 在线看国产一区二区| 午夜精品免费在线观看| 欧美一级在线观看| 国产久卡久卡久卡久卡视频精品| 国产欧美精品一区二区色综合朱莉| 成人午夜免费电影| 一区二区成人在线视频| 欧美日韩电影在线播放| 经典三级视频一区| 亚洲特黄一级片| 6080yy午夜一二三区久久| 精品亚洲成av人在线观看| 国产精品久久看| 欧美日韩激情一区二区三区| 捆绑紧缚一区二区三区视频| 欧美经典三级视频一区二区三区| 91福利在线观看| 久久精品国产亚洲高清剧情介绍 | 韩国精品免费视频| 综合久久一区二区三区| 在线成人免费观看| 国产成人精品三级| 天堂午夜影视日韩欧美一区二区| 欧美精品一区二区久久婷婷| 97久久精品人人爽人人爽蜜臀| 亚洲成人三级小说| 国产精品丝袜一区| 日韩精品一区二区三区视频播放 | 美女网站视频久久| 亚洲三级电影全部在线观看高清| 欧美一区二区三区精品| 99久久综合99久久综合网站| 日本美女一区二区| 亚洲视频综合在线| 国产欧美综合在线观看第十页| 欧美日韩国产成人在线免费| 国产成人av电影在线观看| 亚洲va欧美va人人爽午夜| 日本一区二区三级电影在线观看| 欧美日韩免费观看一区二区三区| 国产成人久久精品77777最新版本| 亚洲成人精品一区| 成人免费在线播放视频| 久久精品亚洲国产奇米99| 91精品国产综合久久久久久漫画| 色综合天天综合色综合av| 国模冰冰炮一区二区| 亚洲欧美另类久久久精品2019| 久久久噜噜噜久久人人看| 日韩精品一区二区三区视频| 在线电影院国产精品| 欧美日韩一区二区在线观看视频 | 亚洲精品免费在线观看| 亚洲国产精品ⅴa在线观看| 日韩欧美国产麻豆| 日韩免费高清av| 欧美一区二视频| 欧美精品黑人性xxxx| 欧美日韩一级二级三级| 欧美日韩一卡二卡三卡 | 亚洲成人av福利| 一区二区三区 在线观看视频 | 久久久99免费| 精品裸体舞一区二区三区| 欧美精品高清视频| 欧美美女一区二区三区| 欧美色成人综合| 欧美精品日韩一区| 777a∨成人精品桃花网| 91精品国产入口| 91精品国产全国免费观看| 7777精品伊人久久久大香线蕉的 | 久久精品亚洲一区二区三区浴池| 欧美成人激情免费网| xfplay精品久久| 国产欧美日产一区| 亚洲色图清纯唯美| 一区二区三区中文免费| 亚洲国产精品一区二区久久| 日韩精品国产精品| 另类小说视频一区二区| 国产一区不卡精品| 99热这里都是精品| 制服丝袜亚洲色图| 精品国产91洋老外米糕| 国产日产亚洲精品系列| 亚洲黄网站在线观看| 日本不卡一二三区黄网| 国产精品99久久久久| 色偷偷一区二区三区| 欧美日韩久久一区二区| 精品少妇一区二区三区视频免付费| 精品福利av导航| 亚洲欧美在线视频| 午夜在线成人av| 国产高清亚洲一区| 在线视频观看一区| 久久综合九色综合欧美98| 成人免费一区二区三区在线观看| 亚洲超碰精品一区二区| 国产成人鲁色资源国产91色综 | 精品国产成人在线影院| 日韩美女久久久| 久久草av在线| 色综合久久久久综合99| 欧美mv和日韩mv的网站| 亚洲自拍都市欧美小说| 国产精品亚洲一区二区三区在线 | 欧美三级韩国三级日本一级| 久久精品一区四区| 日韩中文字幕1| eeuss鲁一区二区三区| 欧美一区二区三区免费视频| 亚洲欧洲美洲综合色网| 国产一区二区在线电影| 欧美视频一区二区三区四区| 国产欧美日产一区| 老司机午夜精品| 欧美午夜理伦三级在线观看| 国产精品美女久久久久久久网站| 日韩电影在线看| 色噜噜狠狠成人中文综合| 2023国产精品视频| 日本午夜一区二区| 欧洲av在线精品| 国产精品不卡一区| 国产一区二区在线观看视频| 8x8x8国产精品| 亚洲午夜三级在线| 在线中文字幕不卡| 国产精品护士白丝一区av| 国产精品亚洲一区二区三区妖精 | 国产福利精品一区二区| 日韩欧美国产1| 天天综合天天综合色| 色偷偷久久一区二区三区| 国产精品免费看片| 国产91综合网| 国产欧美日产一区| 国产精品一卡二卡| 久久精品亚洲麻豆av一区二区| 久久精品国产网站| 欧美一卡2卡3卡4卡| 日韩国产欧美一区二区三区| 欧美日韩美女一区二区| 亚洲高清视频中文字幕| 欧美视频一区二区| 亚洲第一搞黄网站| 欧美日韩国产系列| 日韩在线一二三区| 日韩女优av电影| 国产一区二区三区综合| 久久亚洲综合av| 成人午夜av电影|