急救!监控打印机
我想做一个监控打印机的程序,包括每次打印的打印人,打印文档名称,打印页数,打印文档大小,打印时间,打印电脑及其它,肯请大家帮助,提供实现方法
[解决办法]
有人要收集打印机的信息,就顺便做了一个。用WMI连接。
On Error Resume Next
strComputer = ". "
Set objWMIService = GetObject( "winmgmts: " _
& "{impersonationLevel=impersonate}!\\ " & strComputer & "\root\cimv2 ")
Set colInstalledPrinters = objWMIService.ExecQuery _
( "Select * from Win32_Printer ")
Wscript.Echo "Name " & vbTab & "Location " & vbTab & "Driver "
iCount = 0
For Each objPrinter in colInstalledPrinters
strName = objPrinter.Name
strLocation = objPrinter.Location
strDriver= objPrinter.DriverName
'Wscript.Echo "Name: " & objPrinter.Name
'Wscript.Echo "Location: " & objPrinter.Location
'Wscript.Echo "Default: " & objPrinter.Default
Wscript.Echo strName & vbTab & strLocation & vbTab & strDriver
iCount = iCount + 1
Next
Wscript.Echo "Total: " & iCount
[解决办法]
获取硬件信息源代码:
http://www.codeproject.com/cs/system/GetHardwareInformation/GetHardwareInfo_Code.zip
获取硬件信息演示程序:
http://www.codeproject.com/cs/system/GetHardwareInformation/GetHardwareInfo_Exe.zip
汉化
http://www.msproject.cn/Article/GetHardwareInformation.aspx
利用using System.Management类来获取相应的硬件知识
Private Sub button1_Click(ByVal sender As Object, ByVal e As EventArgs)
If (PrinterSettings.InstalledPrinters.Count <= 0) Then
MessageBox.Show( "没找到打印机 ")
End If
Dim ps As New PrinterSettings
Dim printName As String
For Each printName In PrinterSettings.InstalledPrinters
ps.PrinterName = printName
Console.WriteLine( "默认打印机:{0}; 是否可用:{1} ", 1} ", ps.IsDefaultPrinter, ps.IsValid)
Next
End Sub
==================================================================
博客空间:http://blog.csdn.net/lovingkiss
资源下载:http://download.csdn.net/user/lovingkiss
Email:loving-kiss@163.com
优惠接单开发,收费带初学者,组件控件定制开发,成品源代码批发
联系方式:Q64180940(请清楚注明业务还是技术咨询) 全天在线
==================================================================
[解决办法]
上面给的有用吗???