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

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

?? usbhidiocdlg.cpp

?? USB 編程必備.詳細說明USB原理及控制方法.
?? CPP
?? 第 1 頁 / 共 2 頁
字號:
// usbhidiocDlg.cpp : implementation file
/*
Project: usbhidioc.cpp
Version: 1.2
Date: 8/17/00
by Jan Axelson (jan@lvr.com)

Purpose: demonstrates USB communications with a HID-class device

Description: 
	Finds an attached HID-class device that matches specific vendor & product IDs.
	Retrieves the device's capabilities.
	Sends two bytes to the device using Input reports.
	Receives two bytes from the device using Output reports. 
	A list box displays a log of activity.
	A Bytes Received list box displays the most recent received report bytes.
	Combo boxes enable the user to select what bytes to send.
	An autoincrement check box causes the application to increment the bytes sent
with each report.
	Clicking the Once button causes the application to exchange one set of reports.
	Clicking the Continuous button causes the application to exchange reports periodically
(every 5 seconds).
	
This application was created with Visual C++ 6's AppWizard as a dialog-based application.

Companion firmware and other sample code is available from www.lvr.com.

I owe a big thank you to the many generous contributors on Usenet and the excellent archive at 
www.deja.com/usenet for helping me with Visual C++ in this project. Other sources I used were 
www.natsemi.com's example HID application and John Hyde's terminal program at 
www.usb-by-example.com.

Send comments, questions, bug reports, etc. to jan@lvr.com.

Fixes: 
1. In the call to SetupDiEnumDeviceInterfaces, the fourth parameter is now MemberIndex instead of 0.
(Thanks to Bob Nathan).
2. free(detailData) was in the wrong place. It's now at the very end of the 
if (Result !=0)
statement. (Thanks to Adam Gresswell.)
3. Added the ApplicationActive flag and code to terminate the ReadReport thread in CUsbhidiocDlg::OnClose.
(Thanks to Sang-Gon Park.)
*/

#include "stdafx.h"
#include "usbhidioc.h"
#include "usbhidiocDlg.h"

#include <wtypes.h>
#include <initguid.h>

#define MAX_LOADSTRING 256

extern "C" {
#include "hidsdi.h"
#include <setupapi.h>
}

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

//function prototypes
bool	FindTheHID();
DWORD WINAPI ReadReport();
void DisplayCurrentTime();
void DisplayData(CString cstrDataToDisplay);
void DisplayInputReport();
void DisplayLastError(CString Operation);
void DisplayReceivedData(char ReceivedByte);
void GetDeviceCapabilities();
void ReadAndWriteToDevice();
void ScrollToBottomOfListBox(USHORT Index);
void WriteReport();

static DWORD StaticIO_Thread(LPVOID);

/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About

class CAboutDlg : public CDialog
{
public:
	CAboutDlg();

// Dialog Data
	//{{AFX_DATA(CAboutDlg)
	enum { IDD = IDD_ABOUTBOX };
	//}}AFX_DATA

	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CAboutDlg)
	protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
	//}}AFX_VIRTUAL

// Implementation
protected:
	//{{AFX_MSG(CAboutDlg)
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};

CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
	//{{AFX_DATA_INIT(CAboutDlg)
	//}}AFX_DATA_INIT
}

void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CAboutDlg)
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
	//{{AFX_MSG_MAP(CAboutDlg)
		// No message handlers
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CUsbhidiocDlg dialog

CUsbhidiocDlg::CUsbhidiocDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CUsbhidiocDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CUsbhidiocDlg)
	m_AutoIncrement = FALSE;
	m_ResultsString = _T("");
	m_strBytesReceived = _T("");
	m_strByteToSend0 = _T("");
	m_strByteToSend1 = _T("");
	//}}AFX_DATA_INIT
	// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}


//Application global variables 
	DWORD		ActualBytesRead;
	bool		ApplicationActive;
	DWORD		BytesRead;
	HIDP_CAPS	Capabilities;
	bool		DeviceDetected;
	HANDLE		DeviceHandle;
	HANDLE		hDevInfo;
	GUID		HidGuid;
	char		InputReport[3];
	ULONG		Length;
	HANDLE		ReadHandle;
	ULONG		Required;
	HANDLE		ThreadHandle;
	DWORD		ThreadID;
	HANDLE		WriteHandle;

void CUsbhidiocDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CUsbhidiocDlg)
	DDX_Control(pDX, IDC_Continuous, m_Continuous);
	DDX_Control(pDX, IDC_AutoIncrement, m_cbutAutoIncrement);
	DDX_Control(pDX, IDC_cboByteToSend1, m_cboByteToSend1);
	DDX_Control(pDX, IDC_cboByteToSend0, m_cboByteToSend0);
	DDX_Control(pDX, IDC_lstBytesReceived, m_BytesReceived);
	DDX_Control(pDX, IDC_LIST2, m_ResultsList);
	DDX_Control(pDX, IDC_Once, m_Once);
	DDX_Check(pDX, IDC_AutoIncrement, m_AutoIncrement);
	DDX_LBString(pDX, IDC_LIST2, m_ResultsString);
	DDX_LBString(pDX, IDC_lstBytesReceived, m_strBytesReceived);
	DDX_CBString(pDX, IDC_cboByteToSend0, m_strByteToSend0);
	DDX_CBString(pDX, IDC_cboByteToSend1, m_strByteToSend1);
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CUsbhidiocDlg, CDialog)
	//{{AFX_MSG_MAP(CUsbhidiocDlg)
	ON_WM_SYSCOMMAND()
	ON_WM_PAINT()
	ON_WM_QUERYDRAGICON()
	ON_BN_CLICKED(IDC_Once, OnOnce)
	ON_EN_CHANGE(IDC_Results, OnChangeResults)
	ON_BN_CLICKED(IDC_Continuous, OnContinuous)
	ON_WM_TIMER()
	ON_WM_CLOSE()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CUsbhidiocDlg message handlers

BOOL CUsbhidiocDlg::OnInitDialog()
{
	CDialog::OnInitDialog();

	//My declares begin here
	int		ByteToSend =0;
	CString	strByteToSend = "";
	CString	strComboBoxText="";
	//End my declares

	// Add "About..." menu item to system menu.

	// IDM_ABOUTBOX must be in the system command range.
	ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
	ASSERT(IDM_ABOUTBOX < 0xF000);

	CMenu* pSysMenu = GetSystemMenu(FALSE);
	if (pSysMenu != NULL)
	{
		CString strAboutMenu;
		strAboutMenu.LoadString(IDS_ABOUTBOX);
		if (!strAboutMenu.IsEmpty())
		{
			pSysMenu->AppendMenu(MF_SEPARATOR);
			pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
		}
	}

	// Set the icon for this dialog.  The framework does this automatically
	//  when the application's main window is not a dialog
	SetIcon(m_hIcon, TRUE);			// Set big icon
	SetIcon(m_hIcon, FALSE);		// Set small icon
	
	/*
	My code begins here.
	Anything that needs to happen when the application starts goes in this routine.
	*/

	//Populate the combo boxes with values from 00 to FF.
	DeviceDetected=FALSE;
	ApplicationActive=TRUE;

	for (ByteToSend=0; ByteToSend < 256; ByteToSend++)
	{
		//Display the value as a 2-digit Hex value.
		strByteToSend.Format("%.2X",ByteToSend);
		//Add the value to the combo boxes.
		m_cboByteToSend0.AddString(strByteToSend);
		m_cboByteToSend1.AddString(strByteToSend);	
	}

	//Select default values for the combo boxes.
	m_cboByteToSend0.SetCurSel(0);
	m_cboByteToSend1.SetCurSel(128);

	//Check the autoincrement check box.
	m_cbutAutoIncrement.SetCheck(1);

	//Set the caption for the Continous button.
	m_Continuous.SetWindowText("Continuous");
	//end my code

	return TRUE;  // return TRUE  unless you set the focus to a control
}

void CUsbhidiocDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
	if ((nID & 0xFFF0) == IDM_ABOUTBOX)
	{
		CAboutDlg dlgAbout;
		dlgAbout.DoModal();
	}
	else
	{
		CDialog::OnSysCommand(nID, lParam);
	}
}

// If you add a minimize button to your dialog, you will need the code below
//  to draw the icon.  For MFC applications using the document/view model,
//  this is automatically done for you by the framework.

void CUsbhidiocDlg::OnPaint() 
{
	if (IsIconic())
	{
		CPaintDC dc(this); // device context for painting

		SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);

		// Center icon in client rectangle
		int cxIcon = GetSystemMetrics(SM_CXICON);
		int cyIcon = GetSystemMetrics(SM_CYICON);
		CRect rect;
		GetClientRect(&rect);
		int x = (rect.Width() - cxIcon + 1) / 2;
		int y = (rect.Height() - cyIcon + 1) / 2;

		// Draw the icon
		dc.DrawIcon(x, y, m_hIcon);
	}
	else
	{
		CDialog::OnPaint();
	}
}

// The system calls this to obtain the cursor to display while the user drags
//  the minimized window.
HCURSOR CUsbhidiocDlg::OnQueryDragIcon()
{
	return (HCURSOR) m_hIcon;
}

/*
My routines (routines specific to this application) start here.
*/

void CUsbhidiocDlg::OnOnce() 
{
	//Click the Once button to read and write one pair of reports.
	ReadAndWriteToDevice();
}


void CUsbhidiocDlg::OnContinuous() 
{
	//Click the Continuous button to
	//begin or stop requesting and sending periodic reports.
	CString Caption;

	//Find out whether Continuous is currently selected 
	//and take appropriate action.
	m_Continuous.GetWindowText(Caption);
	if (Caption == "Continuous")
	{
		//Enable periodic exchanges of reports.
		//Change the button caption.
		m_Continuous.SetWindowText("Stop Continuous");
		//Start by reading and writing one pair of reports.
		ReadAndWriteToDevice();
		//Enable the timer to cause periodic exchange of reports.
		SetTimer(ID_CLOCK_TIMER, 5000, NULL);
	}
	else
	{
		//Stop periodic exchanges of reports.
		//Change the button caption.
		m_Continuous.SetWindowText("Continuous");
		//Disable the timer.
		KillTimer(ID_CLOCK_TIMER);
	}
}

void CUsbhidiocDlg::OnClose() 
{
	//Anything that needs to occur on closing the application goes here.

	//Free any resources used by previous API calls and still allocated.

	//Setting ApplicationActive FALSE signals the ReadReport thread to close.
	ApplicationActive=FALSE;
	//Wait for the ReadReport thread to close.
	WaitForSingleObject(ThreadHandle, INFINITE);

	//Close open handles.
	CloseHandle(DeviceHandle);
	DisplayLastError("CloseHandle(DeviceHandle)");
	CloseHandle(ReadHandle);
	DisplayLastError("CloseHandle(ReadHandle)");
	CloseHandle(ThreadHandle);
	DisplayLastError("CloseHandle(ThreadHandle)");

	CDialog::OnClose();
}

bool CUsbhidiocDlg::FindTheHID()
{
	//Use a series of API calls to find a HID with a matching Vendor and Product ID.

	HIDD_ATTRIBUTES						Attributes;
	PSP_DEVICE_INTERFACE_DETAIL_DATA	detailData;
	SP_DEVICE_INTERFACE_DATA			devInfoData;
	bool								LastDevice = FALSE;
	int									MemberIndex = 0;
	bool								MyDeviceDetected = FALSE; 
	LONG								Result;


	//These are the vendor and product IDs to look for.
	//Uses Lakeview Research's Vendor ID.
	const unsigned int VendorID = 0x0925;
	const unsigned int ProductID = 0x1234;

	Length = 0;
	detailData = NULL;
	DeviceHandle=NULL;

	/*
	API function: HidD_GetHidGuid
	Get the GUID for all system HIDs.
	Returns: the GUID in HidGuid.
	*/

	HidD_GetHidGuid(&HidGuid);	
	
	/*
	API function: SetupDiGetClassDevs
	Returns: a handle to a device information set for all installed devices.
	Requires: the GUID returned by GetHidGuid.
	*/
	
	hDevInfo=SetupDiGetClassDevs \
		(&HidGuid, \
		NULL, \
		NULL, \
		DIGCF_PRESENT|DIGCF_INTERFACEDEVICE);
		
	devInfoData.cbSize = sizeof(devInfoData);

	//Step through the available devices looking for the one we want. 
	//Quit on detecting the desired device or checking all available devices without success.
	MemberIndex = 0;
	LastDevice = FALSE;

	do
	{
		MyDeviceDetected=FALSE;
		
		/*
		API function: SetupDiEnumDeviceInterfaces
		On return, MyDeviceInterfaceData contains the handle to a
		SP_DEVICE_INTERFACE_DATA structure for a detected device.
		Requires:
		The DeviceInfoSet returned in SetupDiGetClassDevs.
		The HidGuid returned in GetHidGuid.
		An index to specify a device.
		*/

		Result=SetupDiEnumDeviceInterfaces \
			(hDevInfo, \
			0, \
			&HidGuid, \
			MemberIndex, \
			&devInfoData);

		if (Result != 0)
		{
			//A device has been detected, so get more information about it.

			/*
			API function: SetupDiGetDeviceInterfaceDetail
			Returns: an SP_DEVICE_INTERFACE_DETAIL_DATA structure
			containing information about a device.
			To retrieve the information, call this function twice.
			The first time returns the size of the structure in Length.
			The second time returns a pointer to the data in DeviceInfoSet.
			Requires:
			A DeviceInfoSet returned by SetupDiGetClassDevs
			The SP_DEVICE_INTERFACE_DATA structure returned by SetupDiEnumDeviceInterfaces.
			
			The final parameter is an optional pointer to an SP_DEV_INFO_DATA structure.
			This application doesn't retrieve or use the structure.			
			If retrieving the structure, set 
			MyDeviceInfoData.cbSize = length of MyDeviceInfoData.
			and pass the structure's address.
			*/
			
			//Get the Length value.
			//The call will return with a "buffer too small" error which can be ignored.
			Result = SetupDiGetDeviceInterfaceDetail \
				(hDevInfo, \
				&devInfoData, \
				NULL, \
				0, \
				&Length, \
				NULL);

			//Allocate memory for the hDevInfo structure, using the returned Length.
			detailData = (PSP_DEVICE_INTERFACE_DETAIL_DATA)malloc(Length);
			
			//Set cbSize in the detailData structure.
			detailData -> cbSize = sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA);

			//Call the function again, this time passing it the returned buffer size.
			Result = SetupDiGetDeviceInterfaceDetail \
				(hDevInfo, \
				&devInfoData, \
				detailData, \
				Length, \
				&Required, \

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久精品国产精品青草| 91精品国产入口| 久久久久九九视频| 日韩成人午夜电影| 欧洲人成人精品| 一区二区三区中文字幕在线观看| 国产99久久久国产精品免费看| 日韩欧美电影一二三| 日韩av电影免费观看高清完整版在线观看| 在线免费观看日本欧美| 亚洲激情图片qvod| 在线精品视频免费播放| 一区二区不卡在线视频 午夜欧美不卡在| 成人精品视频一区二区三区| 亚洲国产精品精华液ab| 成人国产电影网| 亚洲精品视频免费观看| 欧美亚洲免费在线一区| 午夜欧美在线一二页| 欧美一区午夜视频在线观看| 免费成人你懂的| 久久久久免费观看| proumb性欧美在线观看| 亚洲欧美一区二区三区极速播放 | 欧美日韩激情在线| 午夜电影网亚洲视频| 精品久久一区二区| 国产99久久久国产精品 | 亚洲成a人v欧美综合天堂下载| 欧美私人免费视频| 免费人成黄页网站在线一区二区| 精品欧美久久久| 成人高清视频在线| 亚洲午夜一二三区视频| 欧美一区二区三区人| 国产精品18久久久久久久久久久久| 国产日产欧产精品推荐色 | 欧美伊人久久大香线蕉综合69| 亚洲成人av福利| 欧美成人女星排名| 99久久99久久综合| 亚洲成av人片在线观看无码| 精品国产乱码久久久久久久久| 成人综合在线观看| 亚洲成av人片在线观看| 久久久久亚洲蜜桃| 欧美三区在线视频| 国产精品888| 亚洲成人激情综合网| 26uuu久久天堂性欧美| 色琪琪一区二区三区亚洲区| 免费美女久久99| 国产精品第13页| 欧美一级理论片| av在线播放不卡| 蜜臀av一级做a爰片久久| 亚洲欧美综合网| 精品毛片乱码1区2区3区| 色老汉一区二区三区| 国产在线日韩欧美| 亚洲国产成人精品视频| 中文字幕免费不卡| 欧美一区二区美女| 色94色欧美sute亚洲线路一久| 精品一区二区在线播放| 亚洲人亚洲人成电影网站色| 26uuu精品一区二区在线观看| 91福利在线播放| 成人黄色a**站在线观看| 蜜臀av在线播放一区二区三区| 亚洲乱码中文字幕| 欧美极品美女视频| 精品国产不卡一区二区三区| 精品视频一区二区不卡| 97久久超碰精品国产| 国产久卡久卡久卡久卡视频精品| 午夜精品免费在线| 一区二区在线免费观看| 国产精品久久久久久一区二区三区| 日韩一区二区三区视频在线观看| 在线观看日韩高清av| a亚洲天堂av| 成人福利视频在线看| 国产在线麻豆精品观看| 麻豆91免费观看| 五月天中文字幕一区二区| 综合色天天鬼久久鬼色| 亚洲国产精品传媒在线观看| 久久青草欧美一区二区三区| 欧美成人性福生活免费看| 欧美精品三级在线观看| 欧美视频一区二区三区| 欧美做爰猛烈大尺度电影无法无天| aa级大片欧美| 99re热视频这里只精品| 成人美女视频在线看| 高清久久久久久| 丁香婷婷综合色啪| 国产丶欧美丶日本不卡视频| 国产一区二区三区美女| 久久99在线观看| 精品一区二区三区蜜桃| 国产综合久久久久久久久久久久 | 99久久精品费精品国产一区二区| 国产一区二区三区日韩| 国产一区二区h| 国产成人精品三级麻豆| 国产91精品精华液一区二区三区| 激情五月婷婷综合网| 久久国产人妖系列| 狠狠色狠狠色综合| 国产成人在线网站| 成人性视频免费网站| 成a人片亚洲日本久久| 一本一本久久a久久精品综合麻豆 一本一道波多野结衣一区二区 | 久久97超碰色| 国产中文一区二区三区| 高清日韩电视剧大全免费| 99综合影院在线| 欧美主播一区二区三区| 欧美精品一二三四| 精品久久久久久亚洲综合网| 久久亚洲欧美国产精品乐播| 欧美国产在线观看| 亚洲免费视频中文字幕| 亚洲精品亚洲人成人网| 天堂在线一区二区| 国产麻豆视频一区| 色呦呦国产精品| 4438x亚洲最大成人网| 久久日韩粉嫩一区二区三区| 最新国产成人在线观看| 午夜久久电影网| 国产精品一区二区黑丝| 色婷婷综合激情| 日韩一区二区三区四区| 国产精品色眯眯| 午夜电影一区二区| 国产成人精品亚洲午夜麻豆| 91捆绑美女网站| 日韩视频免费观看高清在线视频| 国产欧美一区二区三区网站 | 91久久精品午夜一区二区| 欧美一区二区三区四区五区| 国产日韩欧美不卡在线| 亚洲一级二级三级在线免费观看| 久久国产精品区| 日本精品一级二级| 久久综合精品国产一区二区三区 | 激情欧美一区二区三区在线观看| 成人av高清在线| 91精品国产麻豆国产自产在线| 国产欧美日韩在线观看| 亚洲v日本v欧美v久久精品| 国产精品亚洲一区二区三区在线| 91福利精品视频| 日本一区二区三区在线不卡| 午夜久久久影院| 91污在线观看| 2024国产精品视频| 午夜精品成人在线视频| 99久久精品久久久久久清纯| 精品国内片67194| 性久久久久久久| 99re视频这里只有精品| 欧美精品一区二区三区视频| 亚洲福中文字幕伊人影院| 波多野结衣亚洲一区| 日韩精品在线网站| 亚洲成人一二三| 91首页免费视频| 国产嫩草影院久久久久| 免费一级片91| 欧美久久久久久蜜桃| 亚洲精品国产品国语在线app| 国产精品系列在线观看| 日韩欧美中文一区| 亚洲一区二区三区免费视频| 99国产精品久久久久久久久久| 久久午夜羞羞影院免费观看| 秋霞电影一区二区| 欧美最猛黑人xxxxx猛交| 中文字幕日韩av资源站| 高清视频一区二区| 国产色一区二区| 国产在线不卡一卡二卡三卡四卡| 欧美肥大bbwbbw高潮| 亚洲在线视频一区| 欧美亚日韩国产aⅴ精品中极品| 中文字幕一区二区三区不卡| 成人午夜看片网址| 国产午夜一区二区三区| 国产成人精品免费一区二区| 久久网站热最新地址| 国产中文一区二区三区| 久久免费国产精品| 国产剧情av麻豆香蕉精品| 久久男人中文字幕资源站| 国产一区视频在线看| 2020国产精品自拍|