How do I find the spool file for the job with a given ID even when spool file pooling is enabled?

房东的猫 提交于 2019-12-09 14:16:17

问题


I would like to copy the spool data for a given Windows print job to an arbitrary location on disk.

I have the job ID of the print job from the Print Spooler API. I know this job has finished spooling. I know the job won't be deleted before I have time to complete whatever I need to do.

If file pooling is disabled, I can do this by looking in the spool directory for the file with format "xxxxx.spl", where xxxxx is the 0-padded job ID.

How can I do this if file pooling is enabled?

I'd be delighted if there was a method that took a job ID and returned a stream of the spool data, but that seems unlikely at this point. Supposedly something similar might be possible using OpenPrinter with "PrinterName,Job xxxx" and ReadPrinter as documented here, but so far I haven't been able to get it to work, and even if I do it looks like it loads the data into memory, and I'm not sure how this will work with large spool files (>1 GB is not unusual).

My second preference would be a way to pass in the ID and get back the location of the file with the spool data on disk (regardless of file pooling setting).

My third preference would be a way to map a pooled file ("FPyyyyy.spl") to the job ID it's for.

Are any of these feasible, or does anybody have a better idea about how to solve this issue?

(Edited to add since it wasn't clear that we were aware of this option): Our fallback is to require that our customers disable spool file pooling by editing the registry for each printer, but we would much prefer avoid this.


回答1:


I figured out why my calls to OpenPrinter were failing and I have successfully read the spool data using OpenPrinter and ReadPrinter, which solves our problem nicely.

I'll still award the bounty to anybody who comes up with a better solution, though.




回答2:


Have you read this?

http://www.undocprint.org/winspool/spool_files

It seems to have everything you need :)

Specifically To Turn Off Spool File Pooling on a Per Printer Queue-Basis

There is also this article about the format of the spool files http://www.codeproject.com/Articles/9720/The-Windows-NT-print-spool-shadow-file-format however but it seems you already know the format and it probably won't be of any help.



来源:https://stackoverflow.com/questions/12866711/how-do-i-find-the-spool-file-for-the-job-with-a-given-id-even-when-spool-file-po

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!