惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Forbes - Security
Forbes - Security
GbyAI
GbyAI
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
S
SegmentFault 最新的问题
Y
Y Combinator Blog
Recorded Future
Recorded Future
博客园 - Franky
I
InfoQ
T
The Blog of Author Tim Ferriss
Recent Announcements
Recent Announcements
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
博客园_首页
阮一峰的网络日志
阮一峰的网络日志
T
Tailwind CSS Blog
Cyberwarzone
Cyberwarzone
The Register - Security
The Register - Security
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
雷峰网
雷峰网
P
Palo Alto Networks Blog
G
GRAHAM CLULEY
Cloudbric
Cloudbric
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
MongoDB | Blog
MongoDB | Blog
F
Full Disclosure
Google DeepMind News
Google DeepMind News
Recent Commits to openclaw:main
Recent Commits to openclaw:main
C
Check Point Blog
爱范儿
爱范儿
The GitHub Blog
The GitHub Blog
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
W
WeLiveSecurity
T
Threat Research - Cisco Blogs
U
Unit 42
N
Netflix TechBlog - Medium
The Cloudflare Blog
Spread Privacy
Spread Privacy
Microsoft Azure Blog
Microsoft Azure Blog
美团技术团队
T
Troy Hunt's Blog
Engineering at Meta
Engineering at Meta
H
Heimdal Security Blog
TaoSecurity Blog
TaoSecurity Blog
C
Cybersecurity and Infrastructure Security Agency CISA
T
Tenable Blog
B
Blog
S
Securelist
H
Hacker News: Front Page
Google Online Security Blog
Google Online Security Blog
G
Google Developers Blog

博客园 - C#初学者009

脱壳学习 如何将字符串动态转换为指定的值类型 - C#初学者009 - 博客园 SQL Server表描述 及 字段描述的增、删、改、查询 关于Wind2003下MSDTC对DTS运行的影响 SQL 标识列起始种子重设 C#跨线程操作控件 通过委托处理,MSDN上又很详细用法的说明 - C#初学者009 - 博客园 .net项目开发工具(V3.0 ) asp.net控件开发基础(5) -- 复杂属性、内嵌属性 - C#初学者009 如何用vb设置默认打印机? 如何使用 SetPrinter 修改打印机设置 用vb做的activex控件打包成cab后如何发布呢? VB中利用CopyMemory使用指针 如何用vb(API)代码设置不规则打印纸尺寸? 如何在 Windows NT 和 Windows 2000 中使用自定义页面大小打印(VB) 确定打印机状态和打印工作状态从Visual Basic 在.NET中实现对象序列化(转) XmlSerializer 常见问题疑难解答(MSDN) TransactionScope和分布式事务 (转) 对象序列化:使用System.Xml.Serialization命名空间(转)
VB怎么检测打印机状态 - C#初学者009 - 博客园
C#初学者009 · 2009-06-14 · via 博客园 - C#初学者009

http://topic.csdn.net/t/20050819/16/4219161.html

VB code

Option Explicit Declare Function MapPhysToLin Lib "WinIo.dll" (ByVal PhysAddr As Long, ByVal PhysSize As Long, ByRef PhysMemHandle) As Long Declare Function UnmapPhysicalMemory Lib "WinIo.dll" (ByVal PhysMemHandle, ByVal LinAddr) As Boolean Declare Function GetPhysLong Lib "WinIo.dll" (ByVal PhysAddr As Long, ByRef PhysVal As Long) As Boolean Declare Function SetPhysLong Lib "WinIo.dll" (ByVal PhysAddr As Long, ByVal PhysVal As Long) As Boolean Declare Function GetPortVal Lib "WinIo.dll" (ByVal PortAddr As Integer, ByRef PortVal As Long, ByVal bSize As Byte) As Boolean Declare Function SetPortVal Lib "WinIo.dll" (ByVal PortAddr As Integer, ByVal PortVal As Long, ByVal bSize As Byte) As Boolean Declare Function InitializeWinIo Lib "WinIo.dll" () As Boolean Declare Function ShutdownWinIo Lib "WinIo.dll" () As Boolean Declare Function InstallWinIoDriver Lib "WinIo.dll" (ByVal DriverPath As String, ByVal Mode As Integer) As Boolean Declare Function RemoveWinIoDriver Lib "WinIo.dll" () As Boolean Public IOStat As Boolean '************************************************************ '* 函数名称:GetPrnStat * '* 功能:根据打印机的内存地址,检测打印机的目前工作状态 * '* 参数:lptport: 要检测的打印机的端口号,如LPT1: * '* 返回值:打印机的工作状态值。 * '* 0:正常 1:缺纸 2:无联系 3:异常(其他错误) * '* 调用:本模块中的API函数InitializeWinIo和GetPortVal * '* 备注:检测的内存地址,是在打印端口所在的基地址上加1; * '* 作者:谷霖 * '* LPT1口的基地址为&H378;LPT2口的基地址为&H278 * '************************************************************ Public Function GetPrnStat(ByVal LptPort As String) As Long Dim PrnAddr As Long On Error Resume Next If IOStat = False Then IOStat = InitializeWinIo() If IOStat Then If UCase(LptPort) = "LPT1:" Then PrnAddr = &H379 ElseIf UCase(LptPort) = "LPT2:" Then PrnAddr = &H279 End If GetPortVal PrnAddr, GetPrnStat, 1 Else GetPrnStat = &HFF End If GetPrnStat = GetPrnStat And &HF8 Select Case GetPrnStat Case &H68, &H58, &H70 GetPrnStat = 1 '缺纸 Case &H78 GetPrnStat = 2 '无联系 Case &HD8 GetPrnStat = 0 '正常 Case Else GetPrnStat = 3 '异常 End Select End Function '************************************************************************* '* 函数功能:检查打印机的状态主函数 * '* 输入参数:PrintName 要检测的打印机名称 * '* 输出参数:checkprinterr * '* 检查结果(0:正常 1:打印机缺纸 2:打印机无联系 3:打印机异常 * '* 4:没有安装打印机 5:打印机名称错误) * '************************************************************************* Public Function CheckPrintErr(ByVal PrintName As String) As Long 'CheckPrintErr参数说明 '0:没有错误 '1:打印机无联系 '2:打印机缺纸 '3:没有安装打印机 Dim printjieguo As Long Dim i As Long, k As Long On Error GoTo ErrCheckPrint If Printers.Count = 0 Then CheckPrintErr = 4 '没有安装打印机 Exit Function End If '检测发票打印机是否可以联系 For i = 0 To Printers.Count - 1 If (Printers(i).DeviceName = PrintName) Then k = k + 1 Exit For End If Next If k = 0 Then '打印机名称错误 CheckPrintErr = 5 Exit Function End If Set Printer = Printers(i) CheckPrintErr = GetPrnStat(Printer.Port) Exit Function ErrCheckPrint: CheckPrintErr = 3 Exit Function End Function