Public Declare Function EnumServicesStatus Lib "advapi32" _ Alias "EnumServicesStatusA" _ (ByVal hSCManager As Long, _ ByVal dwServiceType As Long, _ ByVal dwServiceState As Long, _ lpServices As Any, _ ByVal cbBufSize As Long, _ pcbBytesNeeded As Long, _ lpServicesReturned As Long, _ lpResumeHandle As Long) As Long
Alias "EnumServicesStatusA" _
(ByVal hSCManager As Long, _
ByVal dwServiceType As Long, _
ByVal dwServiceState As Long, _
lpServices As Any, _
ByVal cbBufSize As Long, _
pcbBytesNeeded As Long, _
lpServicesReturned As Long, _
lpResumeHandle As Long) As Long
操作系统: windows98 windows2000
编程工具: vb6.0
问题: 请问如何在vb中实现:
1.如何检测我的操作系统中是否安装了打印机和打印机是否已经打开?
2.如何检测我当前的打印机的状态是否允许我进行打印作业?非常感谢!
水平: 刚入门 A回答: VB有个Printers对象,要知道是否安装了打印机,只需要看Printers.Count的值就可以了,它表示系统安装的打印机的数目。
检测打印机状态可以参考QA001205 "如何检测打印机是否联机"。不过一般的Windows程序不自己检测打印机状态,因为Windows自己的打印管理器可以很好地管理打印任务,自己管理既麻烦,效果还不一定好。
阿东的意见:
其实还有个打印驱动名称的属性Printer.DeviceName="" 表示没有安装默认打印机。 此问题由李海回答。