Stefan Westner wrote:
Has it really been 13 years already? Wow, I swear the years are not as
long as they used to be <g>.
I gave it a look under Delphi 2007 and in general it works fine but
with some problems:
1. The document name is always "Lokale Druckerdatendatei" (english:
local printerdatafile) and not for example "Microsoft Word -
Document1" as the job is listed in the spooler
Do you see this for a notification with the notification code
JOB_NOTIFY_FIELD_DOCUMENT? That would indicate that the problem is in
the print spooler or driver. I don't remember which notification the
sample application I posted displays here, sorry.
2. If I compile the code with range checks on then I get errors at
runtime:
For i:=0 To pni^.Count-1 Do
Case pni^.aData[i].Field Of
TPrinterNotifyInfoData is created by windows in the message Count-1
but in the WinSpool it is only declared as array[0..0].
_PRINTER_NOTIFY_INFO = record
Version: DWORD;
Flags: DWORD;
Count: DWORD;
aData: array[0..0] of TPrinterNotifyInfoData;
end;
Switching of range check and accessing it count-1 would be ok but
that's more a C-way then a delphi way. How could this solved more
delphi-like?
Unfortunately not. The printer and spooler API is very C-oriented and
full of C structures that are actually of variable size and thus cannot
be exactly declared as a Delphi record. A declaration like the above
one is the closest you can get, and it only works if range checking is
off.
3. Pagenumber, Print data Size, ... are not read vom the spoolerdata
See
https://msdn.microsoft.com/en-us/library/windows/desktop/dd162854%28v=vs
.85%29.aspx for the docs on what to expect in the notification.
The code I posted was basically a Delphi translation of a C code
example posted by somebody else, and I had no real way to test the
result due to a lack of a suitable test system.
--
Peter Below
TeamB
Connect with Us