Turn WORD WRAP ON for this document

Information for W97DuPlx.DLL

Steve Conner
Systems Analyst
Ashurst Morris Crisp
steve.conner@ashursts.com

Obviously the dll needs to be copied to a directory that is in the path, the best place being \WINDOWS\SYSTEM or \WINNT\SYSTEM32

the declare for the DLL is 
Public Declare Function SetDuplexMode Lib "W97DuPlx" Alias "_SetDuplexMode@8" (ByVal PrinterName As String, ByVal DuplexMode As Integer)

The Alias part is required exactly as shown above thanks to C++ using overloaded functions and name mangling (I'm still not sure how to get a nice alias name ?)

the function takes two parameters

PrinterName which is the friendly name for the printer (see the DuplexPrint Macro in Duplex.dot)

DuplexMode which can be 1,2 or 3

1 = Off (Normal Printing)
2 = Horizontal (Long Page)
3 = Vertical (Facing Pages)

The function returns a value dependant upon success

0 = Success
5 = Access Denied
1801 = Invalid Printer Name

you can get a list of all other errors from WINERROR.H, but the above should be the most common.



A Note about the Access Denied error.

All printer information is held within a DEVMODE structure that sits inside the regkey

\\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Print\Printers\[PrinterName]\Default DevMode

obviously this key isn't writable by a normal Domain User, so in order to allow users access to this regkey you need to grant FULL CONTROL or Play Around with the Special Access ... Settings (Grant them all except delete) and then give the Everyone global group access at the \\HKEY_LOCAL_MACHINE\SYSTEN\CurrentControlSet\Control\Print\Printers level. This enables the DLL to set PRINTER_ALL_ACCESS and update the DEVMODE structure.

Your systems administrator can do this from the Polices and Profiles stuff using regedt32.


All the best.