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

推荐订阅源

博客园 - 司徒正美
大猫的无限游戏
大猫的无限游戏
Scott Helme
Scott Helme
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
S
Secure Thoughts
Google DeepMind News
Google DeepMind News
博客园_首页
Hacker News: Ask HN
Hacker News: Ask HN
量子位
Jina AI
Jina AI
I
InfoQ
V
V2EX
Martin Fowler
Martin Fowler
Y
Y Combinator Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
人人都是产品经理
人人都是产品经理
B
Blog
IT之家
IT之家
云风的 BLOG
云风的 BLOG
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
博客园 - Franky
博客园 - 【当耐特】
N
Netflix TechBlog - Medium
Cloudbric
Cloudbric
H
Heimdal Security Blog
TaoSecurity Blog
TaoSecurity Blog
S
Security @ Cisco Blogs
U
Unit 42
Project Zero
Project Zero
Webroot Blog
Webroot Blog
The Register - Security
The Register - Security
N
News | PayPal Newsroom
Microsoft Security Blog
Microsoft Security Blog
H
Help Net Security
Forbes - Security
Forbes - Security
宝玉的分享
宝玉的分享
Last Week in AI
Last Week in AI
C
Check Point Blog
博客园 - 聂微东
M
MIT News - Artificial intelligence
有赞技术团队
有赞技术团队
D
DataBreaches.Net
Cyberwarzone
Cyberwarzone
N
News and Events Feed by Topic
N
News and Events Feed by Topic
Simon Willison's Weblog
Simon Willison's Weblog
J
Java Code Geeks
G
Google Developers Blog
GbyAI
GbyAI
T
Threatpost

博客园 - 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