阅读:14027回复:23
用InstallShield开发驱动安装程序的方法
这是一个MP3 Player在win98下的驱动程序安装包的例子,开发工具是InstallShield6.2。
其功能是实现Driver的自动安装,原始文件是StMp3Rec.inf,StUms.inf,StMp3Rec.sys, StUms.sys,StUmsPdr.pdr。供大家参考,以便快速掌握InstallShield开发98驱动安装程序的方法。 创建驱动程序包的步骤 一、用向导生成一个工程。 二、创建Files Groups 1、Inf Files 包含文件:StMp3Rec.inf, StUms.inf, 安装目录:<WINDIR>\inf 2、Sys Files 包含文件:StMp3Rec.sys, StUms.sys, 安装目录:<WINDIR>\System32\Drivers 3、Pdr Files 包含文件:StUms.pdr, 安装目录:<WINSYSDIR>\iosubsys 4、App Files 包含文件:无 三、创建Componets 1. Inf Files 2、Sys Files 3、Pdr Files 4、App Files 并指定它们和Files Groups的组件一一对应。 四、创建卸载菜单 新建Uninstall快捷方式,Target: <DISK1TARGET>\setup.exe Install Conditions: App Files 五、写InstallScrip代码 //////////////////////////////////////////////////////////////////////////////// // // File Name: Setup.rul // // Description: InstallShield script // // Comments: This script was generated based on the selections you made in // the Project Wizard. Refer to the help topic entitled "Modify // the script that the Project Wizard generates" for information // on possible next steps. // //////////////////////////////////////////////////////////////////////////////// // Include header files #include "ifx.h" ////////////////////// string defines //////////////////////////// //////////////////// installation declarations /////////////////// // ----- DLL function prototypes ----- // your DLL function prototypes // ---- script function prototypes ----- // your script function prototypes // your global variables ////////////////////////////////////////////////////////////////////////////// // // FUNCTION: OnBegin // // EVENT: Begin event is always sent as the first event during installation. // ////////////////////////////////////////////////////////////////////////////// function OnBegin() begin if (!(SYSINFO.WIN9X.bWin98)) then MessageBox("The installation only for Windows 98.",INFORMATION); abort; endif; //delete device infomation RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE); RegDBDeleteKey("Enum\\USB\\VID_066F&PID_8000"); end; ////////////////////////////////////////////////////////////////////////////// // // FUNCTION: OnFirstUIBefore // // EVENT: FirstUIBefore event is sent when installation is run for the first // time on given machine. In the handler installation usually displays // UI allowing end user to specify installation parameters. After this // function returns, ComponentTransferData is called to perform file // transfer. // /////////////////////////////////////////////////////////////////////////////// function OnFirstUIBefore() number nResult,nSetupType; string szTitle, szMsg; LIST listStartCopy; begin // TO DO: if you want to enable background, window title, and caption bar title // SetTitle( @TITLE_MAIN, 24, WHITE ); // SetTitle( @TITLE_CAPTIONBAR, 0, BACKGROUNDCAPTION ); // Enable( FULLWINDOWMODE ); // Enable( BACKGROUND ); // SetColor(BACKGROUND,RGB (0, 128, 128)); TARGETDIR = PROGRAMFILES ^@COMPANY_NAME ^@PRODUCT_NAME; Dlg_Start: // beginning of dialogs label Dlg_SdWelcome: szTitle = ""; szMsg = ""; nResult = SdWelcome( szTitle, szMsg ); if (nResult = BACK) goto Dlg_Start; // setup default status SetStatusWindow(0, ""); Enable(STATUSEX); StatusUpdate(ON, 100); return 0; end; /////////////////////////////////////////////////////////////////////////////// // // FUNCTION: OnFirstUIAfter // // EVENT: FirstUIAfter event is sent after file transfer, when installation // is run for the first time on given machine. In this event handler // installation usually displays UI that will inform end user that // installation has been completed successfully. // /////////////////////////////////////////////////////////////////////////////// function OnFirstUIAfter() STRING szTitle, szMsg1, szMsg2; NUMBER nReserved; begin Disable(STATUSEX); ShowObjWizardPages(NEXT); szMsg1 = SdLoadString(IFX_SDFINISH_MSG1); nReserved = 0; SdFinishReboot(szTitle, szMsg1, SYS_BOOTMACHINE,szMsg2,nReserved); end; /////////////////////////////////////////////////////////////////////////////// // // FUNCTION: OnMoving // // EVENT: Moving event is sent when file transfer is started as a result of // ComponentTransferData call, before any file transfer operations // are performed. // /////////////////////////////////////////////////////////////////////////////// function OnMoving() string szAppPath; begin // Set LOGO Compliance Application Path // TO DO : if your application .exe is in a subfolder of TARGETDIR then add subfolder szAppPath = TARGETDIR; RegDBSetItem(REGDB_APPPATH, szAppPath); RegDBSetItem(REGDB_APPPATH_DEFAULT, szAppPath ^ @PRODUCT_KEY); end; /////////////////////////////////////////////////////////////////////////////// // // FUNCTION: OnMaintUIAfter // // EVENT: MaintUIAfter event is sent after file transfer, when end user runs // installation that has already been installed on the machine. Usually // this happens through Add/Remove Programs applet. // In the handler installation usually displays UI that will inform // end user that maintenance/uninstallation has been completed successfully. // /////////////////////////////////////////////////////////////////////////////// function OnMaintUIAfter() STRING szTitle, szMsg1, szMsg2, szOption1, szOption2; NUMBER bOpt1, bOpt2; begin Disable(STATUSEX); ShowObjWizardPages(NEXT); //Delete device information RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE); RegDBDeleteKey("Enum\\USB\\VID_066F&PID_8000"); bOpt1 = FALSE; bOpt2 = FALSE; szMsg1 = SdLoadString(IFX_SDFINISH_MAINT_MSG1); szTitle = SdLoadString(IFX_SDFINISH_MAINT_TITLE); SdFinishEx(szTitle, szMsg1, szMsg2, szOption1, szOption2, bOpt1, bOpt2); end; // --- include script file section --- |
|
沙发#
发布于:2004-07-15 21:18
可以实现,你注意一下inf,sys文件安装的目录,再试试看.
inf: <WINDIR> 下inf sys: <WINDIR> 下System32 下Drivers |
|
板凳#
发布于:2004-07-20 08:25
To xuquanyong:
如果你是Win2000,WinXP那么还要增加以下处理,内容是以前的一张贴子,在此引用。 首先说一下我的资源何我的目标: 我有两个文件,scap.sys和scap.inf,我的环境是InstallShield Developer 8 ,我希望最终可以制作出一个安装包,执行后可以自己实现驱动的安装。安装的平台为Windows 2000 或windows XP 下面是我找到的资料列出来: 1)这是InstallShield的官方网站上的一遍文档: HOWTO: Launching an .inf File Via InstallScript 文档ID: Q102851 如何通过安装脚本来实现.inf的安装 为可以实现安装.inf文件,可以在安装脚本中通过调用LaunchAppAndWait函数启动一个命令行方式实现: Windows 9x Rundll.exe setupx.dll,InstallHinfSection DefaultInstall 132 %1 Windows NT/2000 Rundll32.exe setupapi.dll,InstallHinfSection DefaultInstall 132 %1 where %1 is the .inf filename. 下面给出例子: Windows 9x szProgram = "rundll.exe"; szCmdLine = "setupx.dll,InstallHinfSection DefaultInstall 132 " + SUPPORTDIR + "test.inf"; LaunchAppAndWait(szProgram, szCmdLine, WAIT); Windows NT / 2000 szProgram = "rundll32.exe"; szCmdLine = "setupapi.dll,InstallHinfSection DefaultInstall 132 + SUPPORTDIR + "test.inf"; LaunchAppAndWait(szProgram, szCmdLine, WAIT); 文档内容我只保留需要的,如果需要详细的资料请根据文档ID到InstallShield上阅读。 2)还是一个例子,是InstallShield里一个老外问的 Q:How can i call an INF file during installation through installshield. I need to do this inorder to install some PDF printers. A: Windows 9x szProgram = "rundll.exe"; szCmdLine = "setupx.dll,InstallHinfSection DefaultInstall 132 " + SUPPORTDIR + "test.inf"; LaunchAppAndWait(szProgram, szCmdLine, WAIT); Windows NT / 2000 szProgram = "rundll32.exe"; szCmdLine = "setupapi.dll,InstallHinfSection DefaultInstall 132 " + SUPPORTDIR + "test.inf"; LaunchAppAndWait(szProgram, szCmdLine, WAIT); SUPPORTDIR is were your inf will be located. 3)网上的大虾都说在安装程序之外写一个执行安装功能的小程序,可以在DDKsrcsetup……找得到,我去看了,同时我也在MSDN上找到了一个文章,就是介绍这个小程序的的 http://support.microsoft.com/default.aspx?scid=http://support.microsoft..com:80/support/kb/articles/q311/2/72.asp&NoWebContent=1 有兴趣自己去看看,我就不罗嗦啦,我把这个程序Devcon下载了下来。 现在我手上有的资料可以使我有两种安装方式,一个是通过InstallShield在安装过程中通过脚本来调用Devcon来实现安装;还有一个是通过在脚本中调用rundll32来实现安装。 顺遍提一下,关于INF文件安装需要调用的函数说明,具体说明请参看Microsoft的MSDN http://msdn.microsoft.com/library/default.asp?url=/library/en-us/setupapi/setup/installing_from_an_inf_file.asp |
|
地板#
发布于:2004-07-28 09:42
To KungFu:
1.SUPPORTDIR是指inf及sys等所有Driver文件所在的路径.你要先把所有Driver文件copy到硬盘,例如你的文件在C:\\YourDriver,则SUPPORTDIR在程序中要替换为 "C:\\\\YourDriver\\\\". 2.如果你的设备是USB设备,则在安装Driver后,要把设备连接到电脑后才会在设备管理器看到设备名称. [编辑 - 7/28/04 by 54cndr] [编辑 - 7/28/04 by 54cndr] |
|
地下室#
发布于:2004-08-13 08:31
To: dcj2004
你可以在google里搜索"InstallShield简明使用教程",就可以找一本电子书,它是InstallShield入门的好书. |
|
5楼#
发布于:2004-12-02 15:45
blackperl:
如果使用Rundll32.exe不行,你可以试试验调用Devcon来实现安装. |
|
6楼#
发布于:2004-12-09 11:26
关于rundll32.exe安装方法
szProgram = "rundll32.exe"; szCmdLine = "setupapi.dll,InstallHinfSection DefaultInstall 132" + SUPPORTDIR + "netsf.inf"; 其中DefaultInstll是指INF文件中的安装节,必须替换为自己INF中的INSTALL节名,例如节名是USBCamera.Dev,则代码要要改为: szCmdLine = "setupapi.dll,InstallHinfSection USBCamera.Dev 132" + SUPPORTDIR + "netsf.inf"; 此方法在2K、XP中经测试有效。 |
|