2007年9月24日 星期一

Win32::Printer

I was looking for the Printer Module on CPAN , and I found this ( Win32::Printer ). The author said that " PPD ( binary package ) is on the waxs.net " , but the link missed.

I have to compile it by myself , it's a troublesome job , because I have to install MSVC 6.0.

After you install MSVC 6.0 , just compile the module:

> perl Makefile.PL
> nmake
> nmake install


but you shall encounter an error which is that "PageNumber" is not in the structure "PSINJECTDATA".

I don't know why. Maybe it was caused by the version of Win32 API Headers. the structure which the module code expects is:
struct PSINJECTDATA {
DWORD DataBytes;
WORD InjectionPoint;
WORD PageNumber;
}
alias PSINJECTDATA* PPSINJECTDATA;
but what I actually have is:
typedef struct _PSINJECTDATA {

DWORD DataBytes; /* number of raw data bytes */
DWORD InjectionPoint; /* injection point */
DWORD Flags; /* flags */
DWORD Reserved; /* reserved field - must be 0 */

/* Followed by raw data to be injected */

} PSINJECTDATA, *PPSINJECTDATA;
My solution is ...
just comment the line:

psd.PageNumber = page;

then it unexpectedly can work out! :P

I can't guarantee that "inject" function could work , but the test script still prints out the example normally.