uses Winapi.WinSpool;

procedure TForm1.Button1Click(Sender: TObject);
var
pi2: PRINTER_INFO_2;
hPrinter: THandle;
Jobs: array [0 .. 1000] of TJobInfo2;
BytesNeeded, NumJobs: Dword;
begin
pi2.pPrinterName := 'Microsoft XPS Document Writer';
if OpenPrinter(pi2.pPrinterName, hPrinter, 0) then
begin
while true do
begin
WaitForPrinterChange(hPrinter, PRINTER_CHANGE_ADD_JOB);
if EnumJobs(hPrinter, 0, 1000, 2, @Jobs, SizeOf(Jobs), BytesNeeded,
NumJobs) then
begin
if NumJobs <> 0 then
begin
with Jobs[NumJobs - 1] do
showmessage(StrPas(pUserName) + StrPas(pMachineName) +
StrPas(pDocument));
end;
end;
end;
end;
end;

可监控的打印机状态参数记录:

_JOB_INFO_2W = record
JobId: DWORD;
pPrinterName: LPWSTR;
pMachineName: LPWSTR;
pUserName: LPWSTR;
pDocument: LPWSTR;
pNotifyName: LPWSTR;
pDatatype: LPWSTR;
pPrintProcessor: LPWSTR;
pParameters: LPWSTR;
pDriverName: LPWSTR;
pDevMode: PDeviceModeW;
pStatus: LPWSTR;
pSecurityDescriptor: PSECURITY_DESCRIPTOR;
Status: DWORD;
Priority: DWORD;
Position: DWORD;
StartTime: DWORD;
UntilTime: DWORD;
TotalPages: DWORD;
Size: DWORD;
Submitted: TSystemTime; { Time the job was spooled }
Time: DWORD; { How many seconds the job has been printing }
PagesPrinted: DWORD;
end;

http://www.cnblogs.com/hnxxcxg/p/4447758.html

监控打印机(使用OpenPrinter,WaitForPrinterChange API函数)的更多相关文章

  1. Windows API 函数列表 附帮助手册

    所有Windows API函数列表,为了方便查询,也为了大家查找,所以整理一下贡献出来了. 帮助手册:700多个Windows API的函数手册 免费下载 API之网络函数 API之消息函数 API之 ...

  2. API函数

    1. API之网络函数 WNetAddConnection 创建同一个网络资源的永久性连接 WNetAddConnection2 创建同一个网络资源的连接 WNetAddConnection3 创建同 ...

  3. WINDOWS API 函数(超长,值得学习)

    一.隐藏和显示光标 函数: int ShowCursor ( BOOL bShow );  参数 bshow,为布尔型,bShow的值为False时隐藏光标,为True时显示光标:该函数的返回值为整型 ...

  4. linux API函数大全

    获取当前执行路径:getcwd1. API之网络函数 WNetAddConnection 创建同一个网络资源的永久性连接 WNetAddConnection2 创建同一个网络资源的连接 WNetAdd ...

  5. Windows API函数大全(精心总结)

    WindowsAPI函数大全(精心总结)    目录 1. API之网络函数... 1 2. API之消息函数... 1 3. API之文件处理函数... 2 4. API之打印函数... 5 5. ...

  6. WINDOWS-API:API函数大全

    操作系统除了协调应用程序的执行.内存分配.系统资源管理外,同时也是一个很大的服务中心,调用这个服务中心的各种服务(每一种服务是一个函数),可以帮肋应用程序达到开启视窗.描绘图形.使用周边设备的目的,由 ...

  7. Windows API函数大全二

    4. API之打印函数 AbortDoc 取消一份文档的打印 AbortPrinter 删除与一台打印机关联在一起的缓冲文件 AddForm 为打印机的表单列表添加一个新表单 AddJob 用于获取一 ...

  8. Windows API函数大全(完整)

    Windows API函数大全,从事软件开发的朋友可以参考下 1. API之网络函数 WNetAddConnection 创建同一个网络资源的永久性连接 WNetAddConnection2 创建同一 ...

  9. Windows API函数大全

    WindowsAPI函数大全(精心总结) 目录 1. API之网络函数... 1 2. API之消息函数... 1 3. API之文件处理函数... 2 4. API之打印函数... 5 5. API ...

随机推荐

  1. 分位数和分位线(Quantiles and Percentiles)

    分位数有种积分(累积)的含义在. 分位数(即将数据由低至高排列,小于该数的数据占总体的比例达到时最终落到的数): 10%:3000元 20%:5200元 50%:20000元 80%:41500元 9 ...

  2. JAVA从本机获取IP地址

    JAVA从本机获取IP地址 论述: 此篇博客是在工作的时候,需要获得当前网络下面正确的ip地址,在网上查阅很多博客,网上一个比较普遍的说法是通过InetAddress.getLocalHost().g ...

  3. ASP.NET Core & Docker & Jenkins 零基础持续集成实战

    原文:ASP.NET Core & Docker & Jenkins 零基础持续集成实战 一.本系列教程说明 源代码管理工具:Gogs 持续集成工具:Jenkins 容器:Docker ...

  4. 防止SQL/XSS攻击

    function clean($str)    {     $str=trim($str);     $str=strip_tags($str);     $str=stripslashes($str ...

  5. NuttX 构建系统

    (嵌入式 实时操作系统 rtos nuttx 7.1 makefile) NuttX 构建系统 转载请注明出处: http://blog.csdn.net/zhumaill/article/detai ...

  6. POJ 2954-Triangle(计算几何+皮克定理)

    职务地址:POJ 2954 意甲冠军:三个顶点的三角形,给出,内部需求格点数. 思考:就像POJ 1265. #include <stdio.h> #include <math.h& ...

  7. Methods and Systems for Enhancing Hardware Transactions Using Hardware Transactions in Software Slow-Path

    Hybrid transaction memory systems and accompanying methods. A transaction to be executed is received ...

  8. Leetcode 226 Invert Binary Tree 二叉树

    交换左右叶子节点 /** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * ...

  9. ASP.NET Core 属性路由 - ASP.NET Core 基础教程 - 简单教程,简单编程

    原文:ASP.NET Core 属性路由 - ASP.NET Core 基础教程 - 简单教程,简单编程 ASP.NET Core 属性路由 经过前面章节的学习,想必你已经对 ASP.NET Core ...

  10. hdu 2037 这个夏天不AC (java)

    问题: 这个题为项贪心算法.我们的想法是在第一时间每个周期根据结束排序(按结束越早穿越,更多的程序), 然后从第一个节目开始.假设下一个节目的开始时间大于一个节目的开始时间,是进行程序,依次递推. 输 ...