虚拟打印的实现-安装

简介:

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

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

当运行到“安装打印机软件”的时候,在右下角有一个“从磁盘安装”按钮。如果我们点击了这个按钮,系统会弹出一个让我们选择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

相关文章
|
监控 Linux
Linux 进程标识符:深入探讨 getpid() 和 getppid()
在Linux操作系统中,进程管理是一项重要的任务。为了正确管理和监控进程,我们需要了解如何获取进程的标识符。本文将详细介绍两个重要的Linux系统调用函数:`getpid()`和`getppid()`。这两个函数用于获取当前进程的进程ID(PID)和父进程的PID。我们将深入探讨它们的用途、使用方法以及示例代码。
2705 0
|
安全 物联网 Linux
IoT技术-用HackRF做一个私网LTE基站
本文中涉及到国家通信安全。请不要随便尝试。如若尝试后造成任何后果与本文作者无任何关系。
1868 1
IoT技术-用HackRF做一个私网LTE基站
|
2月前
|
存储 Ubuntu 安全
在Ubuntu 16.04上安装openjdk-6/7/8-jdk的步骤
在整个安装过程中,你可能需要管理员权限,因此你可能要使用 `sudo` 来获取必要的权限。记得做完每一个步骤后,都要检查输出,以确保没有发生错误,并且每项操作都成功完成。如果在安装过程中遇到问题,查看 `/var/log/` 下的日志文件对于问题的解决可能是有帮助的。
124 21
|
监控 数据安全/隐私保护
Smtp邮件发送失败情况汇总
Smtp邮件发送失败情况汇总
706 0
|
监控 安全 Linux
docker 命令 --cap-add NET_ADMIN 什么作用
`--cap-add NET_ADMIN` 是 Docker 容器运行时的一个参数,用于添加网络管理员权限(NET_ADMIN capability)给容器。 在 Linux 系统中,每个进程都有特定的权限来执行特定的操作。网络管理员权限是一种较高级的权限,它允许容器内的进程执行一些需要网络配置和管理的操作,例如配置网络接口、修改路由表、设置防火墙规则等。 通过添加 `--cap-add NET_ADMIN` 参数,Docker 容器将获得网络管理员权限,使其能够执行更高级的网络操作。这对于某些特定的应用场景,如网络监控、网络测试等非常有用。 需要注意的是,使用网络管理员权限可能存在安全
2718 1
|
数据采集 机器学习/深度学习 Web App开发
提升爬虫OCR识别率:解决嘈杂验证码问题
使用OCR技术提升爬虫识别嘈杂验证码的准确率,结合Python代码示例展示了如何预处理图像、使用Tesseract和代理IP来规避反爬。通过灰度化、二值化增强验证码可读性,并利用代理IP保持爬虫稳定性。
434 0
|
JavaScript 安全 前端开发
原生JS实现一键复制,一键粘贴
原生JS实现一键复制,一键粘贴
218 0
|
Docker 容器
docker重命名镜像名称以及tag版本
docker重命名镜像名称以及tag版本
715 0