我使用以下代码从spl文件中获取副本数量。对于Windows 2008服务器生成的spl文件,没有SpoolerRecordTypes.SRT_DEVMODE。
Private Sub SkipAHeader(ByVal Header As EMFMetaRecordHeader, ByRef SpoolBinaryReader As BinaryReader)
With Header
If .nSize <= 0 Then
.nSize = 8
End If
If .iType = SpoolerRecordTypes.SRT_JOB_INFO Then
Dim JobInfo() As Byte
JobInfo = SpoolBinaryReader.ReadBytes(.nSize)
SpoolBinaryReader.BaseStream.Seek(.Seek + .nSize, SeekOrigin.Begin)
ElseIf .iType = SpoolerRecordTypes.SRT_EOF Then
'\\ End of file reached..do nothing
ElseIf .iType = SpoolerRecordTypes.SRT_DEVMODE Then
'\\ Spool job DEVMODE
Dim _dmThis As New DevMode(SpoolBinaryReader)
_Copies = _dmThis.Copies
SpoolBinaryReader.BaseStream.Seek(.Seek + 8 + .nSize, SeekOrigin.Begin)
ElseIf .iType = SpoolerRecordTypes.SRT_PAGE Or .iType = SpoolerRecordTypes.SRT_EXT_PAGE Then
'\\
Call ProcessEMFRecords(Header, SpoolBinaryReader)
ElseIf .iType = SpoolerRecordTypes.SRT_EOPAGE1 Or .iType = SpoolerRecordTypes.SRT_EOPAGE2 Then
'\\ int plus long
Dim EOPAGE() As Byte
EOPAGE = SpoolBinaryReader.ReadBytes(.nSize)
If .nSize = &H8 Then
SpoolBinaryReader.BaseStream.Seek(.Seek + .nSize + 8, SeekOrigin.Begin)
End If
ElseIf .iType = SpoolerRecordTypes.SRT_UNKNOWN Then
SpoolBinaryReader.BaseStream.Seek(.Seek + 4, SeekOrigin.Begin)
Else
SpoolBinaryReader.BaseStream.Seek(.Seek + .nSize, SeekOrigin.Begin)
End If
End With
End Sub