且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

虚拟打印的实现-安装

更新时间:2022-09-21 18:01:01

通过以上几篇的说明,我想大家一定会开发自己的虚拟打印了。但是,我们开发出来的虚拟打印又如何安装到系统中呢?这次我就来写一下如何将我们编写的虚拟打印安装到系统中。

我们知道,当我们使用“开始”-》“设置”-》“打印机和传真”-》“添加打印机”会出现安装打印机向导。

当运行到“安装打印机软件”的时候,在右下角有一个“从磁盘安装”按钮。如果我们点击了这个按钮,系统会弹出一个让我们选择INI文件的界面。

好了,既然这样,我们就可以编写或者改造一个自己的打印机安装INI文件。

首先,我们去网上随便下载一个打印机驱动安装包,并将我们自己编写的genprint.dll拷入。然后编写我们的INI文件。(以下是我写好的一个INI文件,我使用的是一款HP的打印机驱动)。

 

 

;Hewlett-Packard LaserJet combined printer driver INF file for Windows XP and 2000
;Copyright Hewlett-Packard 2001

; List of supported printers, manufacturers
[Version] 
Signature="$Windows NT$"
Provider=%虚拟打印%
ClassGUID={4D36E979-E325-11CE-BFC1-08002BE10318}
Class=Printer
DriverVer=1/18/2002,02.00.12.02

; Manufacturer section.
;
; This section lists all of the manufacturers
; that we will display in the Dialog box
[Manufacturer]
%虚拟打印%=DefaultInstall


;
; MS Driver Core installs
;
; These sections are used by Printer OEMs to install MS provided drivers

; Installer Sections
;
; These sections control file installation, and reference all files that
; need to be copied. The section name will be assumed to be the driver
; file, unless there is an explicit DriverFile section listed.
;
; Note: Pulling HPLJ4.GPD via Needs= directive to get pcl5eres.dll from XP 
;       drivers.cab file due to XP defect whereby this file wasn't listed
;       This also takes care of pjlmon.dll, ttfsub.gpd, UNIDRV sections
;       but unavoidably brings with it the unneeded hplj4.gpd file. 
;       
;   In the case of the LJ4 install does Needs=HPLJ4.GPD overwrite the 
;   just copied newer version of hplj4.gpd??? In this case perhaps, use
;   Needs=HPLJ4L.GPD to avoid this issue?

;
; Phase II GPDs

[DefaultInstall]
"虚拟打印机"                 = HPLJ4L.GPD.XP        ,Hewlett-PackardLaserC029,HP_LaserJet_4L

;Hewlett-PackardLaserC029是设备的ID

;
; XP
;Old CopyFiles statement before use of Includes= & Needs= ...
;CopyFiles=HPPRPROC,UI,RENDER,@HPLJ4.GPD,@hpc02.ini,RES_COMMON,HELP,UNIDRV,PJLMON.DLL,@TTFSUB.GPD

[HPLJ4L.GPD.XP]
CopyFiles=HPPRPROC,@HPLJ4L.GPD,@hpcstr02.dll
Include=NTPRINT.INF
Needs=HPLJ4.GPD
DataSection=HP_UNIDRV_BIDI_DATA
DataFile=HPLJ4L.GPD
PrintProcessor=%PRINT_PROCESSOR%


; Copy Sections
;
; Lists of files that are actually copied. These sections are referenced
; from the installer sections, above. Only create a section if it contains
; two or more files (if we only copy a single file, identify it in the
; installer section, using the @filename notation) or if it's a color
; profile (since the DestinationDirs can only handle sections, and not
; individual files).


[RES_COMMON]
pcl5eres.dll
hpcstr02.dll


[HPPRPROC]
genprint.dll,,,0x00000020


;
; Data Sections
;
[HP_UNIDRV_DATA]
DriverFile=UNIDRV.DLL
ConfigFile=UNIDRVUI.DLL
HelpFile=UNIDRV.HLP

; Data section that attaches PJLMON as the driver Lang Monitor
[HP_UNIDRV_BIDI_DATA]
DriverFile=UNIDRV.DLL
ConfigFile=UNIDRVUI.DLL
HelpFile=UNIDRV.HLP
LanguageMonitor=%PJL_MONITOR%


;
; Call SetupSetDirectoryId with 66000 to set the target directory at runtime
; (depending on which environment drivers are getting installed)
;

[DestinationDirs]
DefaultDestDir=66000
HPPRPROC=66001
PJLMON.DLL=66002

;
; Control Flags
;
[ControlFlags]
ExcludeFromSelect = HWP20D0, HWP21A0, HWP2140, HWP20F0

;
;  Source Disk Section
;  This was added to enable Web Point&Print.
;  All files added to this must also be added to Layout.INF
;

[SourceDisksNames]
1=%DiskID1%,,,""

[SourceDisksFiles]
;
; MS Files
;
PCL5ERES.DLL = 1
UNIDRV.DLL   = 1
UNIRES.DLL   = 1
UNIDRVUI.DLL = 1
STDNAMES.GPD = 1
UNIDRV.HLP   = 1
TTFSUB.GPD   = 1

;
; Phase II
;
HPCUI02.DLL  = 1
HPCRD02.DLL  = 1
HPCFNT02.DLL = 1
HPCSTR02.DLL = 1
genprint.dll  = 1
HPCLJX02.HLP = 1

HPC02.INI    = 1
HPOEMUI.DLL  = 1
HPCMBOX.INI  = 1
HPLJ4L.GPD   = 1
;
; Localizable Strings
;

[Strings]
PrinterClassName="Printers"
DiskID1="虚拟打印安装盘"
PJL_MONITOR="PJL Language Monitor,PJLMON.DLL"
;PRINT_PROCESSOR="HPPRN02,hpprn02.dll"
PRINT_PROCESSOR="Vprint,genprint.dll"
虚拟打印="虚拟打印"

这样就写好了一个打印机的安装INI文件。当你使用这个虚拟打印打印东西的时候,系统就会调用我们的genprint.dll,但是如何调用Print_Dll.dll和SetPrint.dll呢?我想只要有编写DLL经验的朋友都知道,将这两个Dll放到系统的SYSTEM32目录下,就可以被我们的genprint.dll来进行调用了。

 

好了至此,我将如何编写一个虚拟打印的完整过程都已经写出来了。希望对编写虚拟打印的朋友有一点帮助。

本文转自狗窝博客51CTO博客,原文链接http://blog.51cto.com/fxh7622/51634如需转载请自行联系原作者


fxh7622