⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 usb开发步骤之软件篇 - 应用程序 - c++-vc教程.htm

📁 USB驱动设计的步骤和主要程序框架
💻 HTM
📖 第 1 页 / 共 3 页
字号:
    href="http://www.netjc.com.cn/chtml/s49/index.html">WPS教程</A> </LI>
    <LI><A title=Office教程 
    href="http://www.netjc.com.cn/chtml/s50/index.html">Office教程</A> </LI>
    <LI><A title=Word教程 
    href="http://www.netjc.com.cn/chtml/s51/index.html">Word教程</A> </LI>
    <LI><A title=Excel教程 
    href="http://www.netjc.com.cn/chtml/s52/index.html">Excel教程</A> </LI>
    <LI><A title=PowerPoint教程 
    href="http://www.netjc.com.cn/chtml/s53/index.html">PowerPoint教程</A> </LI>
    <LI><A title=Visio教程 
    href="http://www.netjc.com.cn/chtml/s54/index.html">Visio教程</A> </LI>
    <LI><A title=输入法教程 
    href="http://www.netjc.com.cn/chtml/s55/index.html">输入法教程</A> </LI></UL></LI>
  <LI onmouseover="this.className='sfhover';" onmouseout="this.className='';"><A 
  title=应用程序 href="http://www.netjc.com.cn/chtml/b13/index.html">应用程序</A> 
  <UL>
    <LI><A title=C++/VC教程 
    href="http://www.netjc.com.cn/chtml/s60/index.html">C++/VC教程</A> </LI>
    <LI><A title=Delphi教程 
    href="http://www.netjc.com.cn/chtml/s61/index.html">Delphi教程</A> </LI>
    <LI><A title=Java教程 
    href="http://www.netjc.com.cn/chtml/s62/index.html">Java教程</A> </LI>
    <LI><A title=VB教程 
    href="http://www.netjc.com.cn/chtml/s63/index.html">VB教程</A> </LI></UL></LI>
  <LI onmouseover="this.className='sfhover';" onmouseout="this.className='';"><A 
  title=电脑常识 href="http://www.netjc.com.cn/chtml/b4/index.html">电脑常识</A> 
  <UL>
    <LI onmouseover="this.className='sfhover1';" 
    onmouseout="this.className='';"><A title=操作系统 
    href="http://www.netjc.com.cn/chtml/s27/index.html">操作系统<FONT 
    face=webdings>4</FONT></A> 
    <UL>
      <LI><A title=Vista 
      href="http://www.netjc.com.cn/chtml/x27/vista/index.html">Vista</A> </LI>
      <LI><A title="Windows XP" 
      href="http://www.netjc.com.cn/chtml/x27/xp/index.html">Windows XP</A> 
</LI>
      <LI><A title="Windows 2003" 
      href="http://www.netjc.com.cn/chtml/x27/2003/index.html">Windows 2003</A> 
      </LI>
      <LI><A title="Windows 2000" 
      href="http://www.netjc.com.cn/chtml/x27/2000/index.html">Windows 2000</A> 
      </LI>
      <LI><A title="Windows 98" 
      href="http://www.netjc.com.cn/chtml/x27/98/index.html">Windows 98</A> 
</LI>
      <LI><A title=Linux 
      href="http://www.netjc.com.cn/chtml/x27/linux/index.html">Linux</A> </LI>
      <LI><A title=Unix 
      href="http://www.netjc.com.cn/chtml/x27/unix/index.html">Unix</A> 
    </LI></UL></LI>
    <LI><A title=硬件 href="http://www.netjc.com.cn/chtml/s28/index.html">硬件</A> 
    </LI>
    <LI><A title=软件 href="http://www.netjc.com.cn/chtml/s29/index.html">软件</A> 
    </LI>
    <LI><A title=互联网 href="http://www.netjc.com.cn/chtml/s30/index.html">互联网</A> 
    </LI>
    <LI><A title=QQ技巧 
    href="http://www.netjc.com.cn/chtml/s31/index.html">QQ技巧</A> </LI>
    <LI><A title=局域网 href="http://www.netjc.com.cn/chtml/s66/index.html">局域网</A> 
    </LI>
    <LI><A title=综合其他 
    href="http://www.netjc.com.cn/chtml/s68/index.html">综合其他</A> </LI></UL></LI>
  <LI onmouseover="this.className='sfhover';" onmouseout="this.className='';"><A 
  title=常用软件 href="http://www.netjc.com.cn/chtml/b10/index.html">常用软件</A> 
  <UL>
    <LI><A title=网络软件 
    href="http://www.netjc.com.cn/chtml/s70/index.html">网络软件</A> </LI>
    <LI><A title=系统工具 
    href="http://www.netjc.com.cn/chtml/s71/index.html">系统工具</A> </LI>
    <LI><A title=应用软件 
    href="http://www.netjc.com.cn/chtml/s72/index.html">应用软件</A> </LI>
    <LI><A title=联络聊天 
    href="http://www.netjc.com.cn/chtml/s73/index.html">联络聊天</A> </LI>
    <LI><A title=图形图像 
    href="http://www.netjc.com.cn/chtml/s74/index.html">图形图像</A> </LI>
    <LI><A title=多媒体类 
    href="http://www.netjc.com.cn/chtml/s75/index.html">多媒体类</A> </LI>
    <LI><A title=行业软件 
    href="http://www.netjc.com.cn/chtml/s76/index.html">行业软件</A> </LI>
    <LI><A title=游戏娱乐 
    href="http://www.netjc.com.cn/chtml/s77/index.html">游戏娱乐</A> </LI>
    <LI><A title=编程开发 
    href="http://www.netjc.com.cn/chtml/s78/index.html">编程开发</A> </LI>
    <LI><A title=安全相关 
    href="http://www.netjc.com.cn/chtml/s79/index.html">安全相关</A> </LI>
    <LI><A title=教育教学 
    href="http://www.netjc.com.cn/chtml/s80/index.html">教育教学</A> 
</LI></UL></LI></UL></DIV>
<DIV id=wz1>
<P><B>您的位置:</B>&nbsp;<A title=网络教程网 
href="http://www.netjc.com.cn/index.html">首页</A>&nbsp;&gt;&gt;&nbsp;<A 
title=应用程序 
href="http://www.netjc.com.cn/chtml/b13/index.html">应用程序</A>&nbsp;&gt;&gt;&nbsp;<A 
title=C++/VC教程 
href="http://www.netjc.com.cn/chtml/s60/index.html">C++/VC教程</A>&nbsp;&gt;&gt;&nbsp;阅读:<STRONG>USB开发步骤之软件篇</STRONG></P></DIV>
<DIV id=left>
<DIV id=left_list>
<DIV class=jg></DIV>
<DIV id=a_title>
<H1>USB开发步骤之软件篇</H1></DIV>
<DIV id=a_qita>【 时间:2007-7-26 | 人气:65 | <SPAN title=把《USB开发步骤之软件篇》添加到收藏夹 
style="CURSOR: pointer" 
onclick="javascript:window.external.AddFavorite('http://www.netjc.com.cn/html/200707/91036.html','USB开发步骤之软件篇 - 网络教程网');">收藏本文</SPAN> 
】 【 字体:<SPAN style="CURSOR: pointer" onclick=javascript:fontZoom(16)>大</SPAN> 
<SPAN style="CURSOR: pointer" onclick=javascript:fontZoom(14)>中</SPAN> <SPAN 
style="CURSOR: pointer" onclick=javascript:fontZoom(12)>小</SPAN> 】</DIV>
<DIV id=a_content>
<DIV id=a_ad>
<SCRIPT type=text/javascript><!--
google_ad_client = "pub-6112697235031941";
google_ad_width = 336;
google_ad_height = 280;
google_ad_format = "336x280_as";
google_ad_type = "text";
//2007-08-19: article_content
google_ad_channel = "4587437945";
google_color_border = "F8FBFE";
google_color_bg = "F8FBFE";
google_color_link = "000033";
google_color_text = "660000";
google_color_url = "008000";
//-->
</SCRIPT>

<SCRIPT src="USB开发步骤之软件篇 - 应用程序 - C++-VC教程.files/show_ads.js" 
type=text/javascript>
</SCRIPT>
</DIV><!-- HEADER --><B>USB开发步骤之软件篇</B><BR>作者:不详<BR><BR>提交者:eastvc 
发布日期:2003-10-22 20:30:15<BR>原文出处:http://www.laogu.com/<BR><BR><BR><!-- DETAILS -->我这里重点的介绍如何写驱动程序,对于一些应用程序我就不做介绍了,因为我对于那些高层的东西写得很少。倘若再讲,有班门弄斧之嫌,呵呵!<BR>作为WIN98和WIN2K推荐的一项新技术来说,USB的驱动程序和以往的直接跟硬件打交道的WIN95的VXD的方式的驱动程序不同,它应该是WDM类型的。<BR><BR>USB的WDM接口框图如下(这个图可以说是USB软件总体框图)<BR><BR><IMG 
height=196 src="" 
width=513><BR><BR>对于HID的设备,就可以采用上图左上边的结构,其它类的话采用右上的结构,其实右边的结构可以又细分成两层,一层是Class 
Driver,一层是Miniport 
Driver。而倒数第三行的UHCD和OpenHCI分别是由INTEL和COMPAQ两位老大定的一个和硬件有关的底层驱动程序标准,各位可以根据所需要的选择。<BR><BR>对于USB的驱动程序,大家还得去了解WDM驱动程序的写法,或者早些时候的NT驱动程序,其实WDM驱动程序可以看做是NT驱动程序的一个update,只是增加了一些新的特性。<BR><BR>“写驱动程序是一个很漫长和繁琐的工作,在此之前,你最好要熟悉硬件,熟悉C/C++,还要用过DDK,会用一些调试程序,如SOFTICE和WINDBG之类。如果一切就绪,你就可以开始写驱动程序,工作的进程有时侯会取决于你的运气”。(这是一位留美的朋友对我说的,我写出来和大家共享)<BR><BR>下面是我从一个朋友那里得到的一篇文章的摘要:<BR><BR><STRONG>NT驱动程序的分层结构</STRONG> 
<BR>驱动程序是指管理某个外围设备的一段程序代码。NT采用更灵活的分层驱动方法,允许杂应用程序和硬件之间 
存在几个驱动程序层次。分层机制允许NT更加广泛地定义驱动程序,包括文件系统、逻辑卷管理器和各种网络组件,各种物理设备驱动程序等等。 <BR><BR>1、 
设备驱动程序 <BR>这些是管理实际数据传输和控制特定类型的物理设备的操作的驱动程序,包括开始和完成I/O操作,处理中断和执行特定的设备要求的任何差错处理。 
<BR><BR>2、 中间驱动程序 
<BR>NT允许在物理设备驱动程序上分层任意数目的中间驱动程序。这些中间层次提供扩展I/O系统的功能一种方法,而不必修改底层的驱动程序。这也是微软鼓吹的他们的系统灵活的一面!实际上我觉得这样反而牺牲了一些效率上的东西。 
<BR><BR>3、 文件系统驱动程序(FSD) <BR>FSD是一类比较特殊的驱动程序,通常负责维护各种文件系统 
所需要的磁盘结构。注意我们并不能使用DDK来开发FSD,而必须使用Microsoft的文件系统开发人员工具包。 
<BR><BR>一般比较少写中间过滤驱动程序,过滤驱动程序它截获和修改高层发送给类驱动程序的请求。这样就允许利用现有类驱动程序的功能,而不必从头开始写所有程序。NT内核模式对象在我们的实际开发过程中的对象是设备,由于端口驱动程序已经隐藏了硬件控制操作,因此我在这里不讲述跟硬件相关的部份。如果今后的开发对象不同,需要对硬件进行操作的时候,可能会对中断、DMA等有比较详细的了解,这些内容可以参考DDK帮助。 
<BR><BR>NT使用对象技术管理所有的数据,下面分别对一般驱动程序所涉及的一些对象做一介绍。不过在介绍这些对象之前,有必要先对驱动程序的结构做一介绍。<BR> <BR><STRONG>驱动程序结构</STRONG> 
<BR>NT驱动程序和一般的DOS/Windows 
C语言程序不一样,它没有main()或者WinMain()函数入口。和DLL类似地,它向操作系统显露一个名称为DriverEntry()的函数,在启动驱动程序的时候,操作系统将调用这个入口。DriverEntry除了做一些必 
要的设备初始化工作外,还初始化一些Dispatch例程入口。我们知道,NT应用和设备驱动程序打交道主要是通过CreateFile、 
ReadFile、WriteFile 和DeviceIoControl等Win32 API来进行 
的。这些API其实都对应着驱动程序的一些Dispatch例程。而驱动程序除了DriverEntry以外,主要就是由这些Dispatch例 
程组成的。例如调用Win32 API CreateFile的时候,操作系统最终转化为对驱动程序IRP_MJ_CREATE功能代码所对应的 
Dispatch例程的调用,如果驱动程序没有提供该例程, CreateFile调用就会失败。 <BR>NT中一些常用的功能代码和Win32 
API的对象关系如下所示。 <BR>功能代码 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
&nbsp; 说明 <BR>IRP_MJ_CREATE 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; &nbsp; 打开设备CreateFile <BR>IRP_MJ_CLEANUP 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&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p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; 向设备发送数据WriteFile 
<BR>IRP_MJ_DEVICE_CONTROL &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; 对用户模式或内核模式客户程序可用的控制操作DeviceIoControl 
<BR>IRP_MJ_INTERNAL_DEVICE_CONTROL 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; 只对内核模式客户程序可用的控制操作 
<BR>IRP_MJ_QUERY_INFORMATION&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
&nbsp; 得到文件的长度GetFileLength <BR>IRP_MJ_SET_INFORMATION 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; 
&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; 设置文件的长度SetFileLength <BR>IRP_MJ_FLUSH_BUFFERS 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -