Click here to Skip to main content
Click here to Skip to main content

The Windows NT print spool shadow file format

By , 2 Mar 2005
 

Introduction

The shd file (spool shadow file) is a small file that accompanies each spooled print job. It contains the information that is used when you query a print job (with the GetJob API) and it is kept in a separate file so that this operation doesn't interfere with the spooling and despooling of a print job. The format of this file is not documented and so it is liable to change between versions of the windows operating system.

Currently it is like this:

  • [INT32] SpoolShadowFileFormat

This can be one of:

Public Enum SpoolShadowFileFormats
  SHD_SIGNATURE_WIN98 = &H494B
  SHD_SIGNATURE_WINNT = &H4966
  SHD_SIGNATURE_WIN2K = &H4967
  SHD_SIGNATURE_WIN2003 = &H4968
End Enum

Then for the newest two spool shadow file formats, we have:

  • [INT32] HeaderSize - The size of the fixed part of this record.
  • [INT16] Status - the job status flags.
  • [INT16] Padding - I'm not sure what (if anything) this is used for though it does often contain non zero values.
  • [INT32] JobId - the unique number of the print job, which is the JobId parameter in any call to GetJob() etc..
  • [INT32] Priority - A number between 1-99 which is the print job priority (higher is more priority).
  • [INT32] OffsetUserName - The offset of the user name that submitted the print job.
  • [INT32] Offset_NotifyName - Offset to the name of the user to notify when the job status changes.
  • [INT32] Offset_DocumentName - Offset to the document name.
  • [INT32] Offset_Port - Offset to the printer port name.
  • [INT32] Offset_PrinterName - Offset to the printer device name.
  • [INT32] Offset_DriverName - Offset to the printer driver name.
  • [INT32] Offset_DEVMODE - Offset to the DEVMODE structure in the file.
  • [INT32] Offset_PrintProcessorName - The offset in the file to the print processor name in the file.
  • [INT32] Offset_DataType - The offset in the file to the data type of the spool file...can be EMF or RAW.
  • [INT16] Year - The year of the date of submission of the print job.
  • [INT16] Month
  • [INT16] Day of week
  • [INT16] Day
  • [INT16] Hour
  • [INT16] Minute
  • [INT16] Second
  • [INT16] Millisecond
  • [INT32] StartTime - The start of the time window for this job.
  • [INT32] EndTime - The end of the time window for this job.
  • [INT32] SpoolFileSize - the size (in bytes) of the spool file.
  • [INT32] PageCount - and lastly the page count of the job.

Note that the dmCopies in this DEVMODE will hold the wrong value when the Microsoft Word multiple copies bug occurs.

Portions of this article based on www.undocprint.org/formats/winspool/shd. These portions are subject to the GNU Free Documentation License and are copyright © 2003-2005 Free Software Foundation, Inc.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Duncan Edwards Jones
Software Developer (Senior) JP Morgan
Ireland Ireland
Member
C# / SQL Server developer
Microsoft MVP 2006, 2007
Visual Basic .NET

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
QuestionMonitor Print Job StatusmemberMatthysDT18 Aug '11 - 2:47 
Should I be able to view this file's contents by making use of a Struct?
If so, I'd like to use a FileSystemWatcher to fire events informing me of each print job's status based on the contents/existence of the SHD file.
 
Is there a better way of doing what I'm proposing? Currently I'm running a continuous WMI query, but it's too expensive i.t.o system resources.
GeneralOn 64 bit platforms ...membertheGyre24 May '07 - 4:58 
SHD files created on 64 bit platforms will have offsets that are INT64 not INT32. (i.e. XP-64, Win2003-64, etc.)
 
An easy method for determining which platform your file was created on is checking the header size. 64 bit = 184 bytes, 32 bit = 120 bytes
 
- theGyre
GeneralRe: On 64 bit platforms ...memberDuncan Edwards Jones24 May '07 - 7:43 
Thanks - very good info, I'll try and get a 64bit machine to do some testing on...
 
'--8<------------------------
Ex Datis:
Duncan Jones
Merrion Computing Ltd

GeneralIsn't this dangerousmemberTony Edgecombe13 Nov '05 - 0:13 
I don't understand why you would access this file directly rather than using the GetJob API. Surely if you read the file yourself you are stuck with never ending problems every time MS release a new service pack/version and change the file format.
 
Tony Edgecombe
www.printdistributor.com
Easy output management
GeneralRe: Isn't this dangerousmemberDuncan Edwards Jones14 Nov '05 - 4:39 
Yes - for jobs still in the print queue GetJob is definitely the prefered method.
This file format is primarily useful for archived job information (where print jobs are copied from the spool queue to a backup store)
 

 
'--8<------------------------
Ex Datis:
Duncan Jones
Merrion Computing Ltd
GeneralHi, about how to parsing .spl filesmemberankea12 Nov '05 - 15:57 
Hi, I want to get the corrent page count of MS-Word document. Through the Internet,I find your artices about this. Can you send me some working codes & documents. I also find your source code in codeproject.com, but it does't work to my spooled .spl file.(My printer is Hp Laser Jet 1012) when i open .spl file, some GDI error occured. and i don't know how to debug it, because they're all wrappered into dlls. could you send me a copy of dll source code ?
 
My E-mail addr: muliu92@sohu.com
GeneralRe: Hi, about how to parsing .spl filesmemberDuncan Edwards Jones14 Nov '05 - 4:45 
Parsing .spl files is more difficult as there are a larger number of possible formats. Files cam be EMF based or RAW printer language. The printer language in that case could be PostScript, PCL-5. PCL-XL (also known as PCL-6) , HP-GL etc.
 

 
'--8<------------------------
Ex Datis:
Duncan Jones
Merrion Computing Ltd
QuestionHow to preview a Job in the Queue or Get the Contents of a Job in the Queuememberankea1 Sep '05 - 22:45 
Hi All
 
How to preview a Job in the Queue or Get the Contents of a Job in the Queue?
 
And
 
I want to decide the Size of The Document which user is printing, not the size of the Printing Job
How to Achive this?
 
welcome to discuess!
 
thanks
AnswerRe: How to preview a Job in the Queue or Get the Contents of a Job in the QueuememberMerrion1 Sep '05 - 23:01 
The first question is tricky but doable - I don't understand what you mean in the second question.
 
To preview all the print jobs in a queue you'd need to ensure that they had fully spooled then read each spool shadow file and determine what language the spool file itself is in then use a viewer appropriate to that language to view the file. There is an "EMF" viewer available in my articles on this site but you would also need to have one for PostScript, PCL-5, PCL-XL and any other printer control languages as might exist in your set-up.
 
'--8<------------------------
Ex Datis:
Duncan Jones
Merrion Computing Ltd
GeneralRe: How to preview a Job in the Queue or Get the Contents of a Job in the Queuememberankea6 Sep '05 - 23:51 
Thanks for your help!
 
Can you give me a weblink to the "EMF" viewer? I can't find it!
 
and
 
I want to get the bytes of the document which the job contains! how to achive it ?

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Permalink | Advertise | Privacy | Mobile
Web01 | 2.6.130523.1 | Last Updated 2 Mar 2005
Article Copyright 2005 by Duncan Edwards Jones
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid