小默

驱动安装包制作 nsis

引用不知道哪位大牛的原话:

对于即插即用简单地说要对付2种情况
1。在你的设备未安装前,安装驱动程序这叫预先安装。
最简单的方法就是使用SetupCopyOEMInf函数。
具体做法是:
将SetupCopyOEMInf封装在一个动态库里。
用installshield将所有文件copy到一个临时目录。
调用动态库使用SetupCopyOEMInf函数copy临时目录下的inf文件(路径)。
installshield让计算机重启。
插上设备,自动识别。 
 2.你的设备已安装,弹出安装向导。
很简单,让用户搜索你的安装盘,即可完成安装。
 
懒得写dll了(其实是不会写- -),devcon dp_add调用SetupCopyOEMInf做了预安装




wdk文档中关于预安装的一段话
我刚开始以为预安装就是直接把驱动安上,白痴似的把驱动直接安上了,然后我机子上面之前的驱动没卸干净,添上设备后直接能用,偶就把安装程序当成一个版本交了,囧。。。

 

Preinstalling Driver Packages

To preinstall driver files, your device installation application should follow these steps:

1. On the target system, create a directory for the driver files. If your device installation application installs an application, the driver files should be stored in a subdirectory of the application directory.

2. Copy all files in the driver package from the distribution media to the directory created in step (1). The driver package includes the driver or drivers, the INF file, the catalog file, and other installation files.

3. Call  SetupCopyOEMInf specifying the INF file in the directory created in step (1). Specify SPOST_PATH for the OEMSourceMediaType parameter and specify NULL for the OEMSourceMediaLocation parameter. SetupCopyOEMInf copies the INF file for the driver package into the %windir%\Inf directory on the target system and directs Windows to store the source location of the INF file in its list of preprocessed INF files. SetupCopyOEMInf also processes the catalog file, so the PnP manager will install the driver the next time it recognizes a device listed in the INF file.

When the user plugs in the device, the PnP manager recognizes the device, finds the INF file copied by SetupCopyOEMInf, and installs the drivers copied in step (2). (For more information about copying INF files, see Copying INFs.)

 


 

安装时直接把inf文件拷windows\inf下,卸载时删除,防止被命名成oem*.inf,在某种情况下发生重复预注册,同时也便于卸载时删除inf文件


 

 未完待续。。。

posted on 2010-02-24 22:58 小默 阅读(4927) 评论(1)  编辑 收藏 引用 所属分类: Windows

评论

# re: 驱动安装包制作 nsis 2011-03-15 17:58 徐凌波

你好,我按照Preinstalling Driver Packages方式将 驱动所需要的inf,sys,dll文件放到了一个目录,并且按照 步骤2的方式调用了 SetupCopyOEMInf 函数。但是重启电脑连接新硬件的时候 电脑还会提示 有新硬件的向导。这是问什么。  回复  更多评论   


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理


导航

统计

留言簿(13)

随笔分类(287)

随笔档案(289)

漏洞

搜索

积分与排名

最新评论

阅读排行榜