Copyright: PowerPrinter v1.1
Citation: PowerPrinter v1.1 - Total Printer Control


Introduction

PowerPrinter v1.1

PowerPrinter is a 32bit DLL that gives you access to all printer settings by means of simple APIs. Moreover, developers are shielded from the differences between Windows 95 and Windows NT because PowerPrinter takes care of the Operating Systems differences.

We also supply modules with ready made declarations and easy to use functions for PowerBuilder Version 5, VisualBasic 4 and Delphi 2 but it can be used with any development tool capable of calling external functions. Please refer to the Sample Applications for more information.

See also:

16 Bit Version

PowerPrinter API Reference

How To Topics

PowerDIB

Ordering PowerPrinter

License Agreement

Support

Version 1.1 Features

Copyright © 1997 by DigitalWave Limited. All rights reserved. Visit us at http://www.digitalw.com

Get in touch with us by email at digitalwave@compuserve.com


How To Topics

The following is a list of topics for common tasks. We will keep updating this list from the feedback we get. There is also an online equivalent at our web site at htpp://www.digitalw.com.

How to get rid of the NAG Screen

How to change printer orientation

How to Get/Set the Default Printer

How to get the list of available printers

How to change Paper Size

How to add a printer

See also:

PowerPrinter API Reference

Support


How to change printer orientation

Most printers allow you to change the orientation. If by setting the printer orientation you get  ERR_PRN_NOCHANGE as return value then it means that you cannot change the orientation because your printer does not support it.

See Error Codes for a description of all error codes.

Values accepted:

DMORIENT_PORTRAIT	which is equal to 1

DMORIENT_LANDSCAPE	which is equal to 2

APIs:

dwGetPrinterOrientation

dwSetPrinterOrientation

PowerBuilder:

nvo_PowerPrn.of_SetPrinterOrientation()

nvo_PowerPrn.of_GetPrinterOrientation()

nvo_PowerPrn.of_GetPrinterOrientationString()

Values: nvo_PowerPrn.DMORIENT_PORTRAIT or nvo_PowerPrn.DMORIENT_LANDSCAPE as argument of of_SetPrinterOrientation()

VisualBasic:

iPowerPrn.of_SetPrinterOrientation()

iPowerPrn.of_GetPrinterOrientation()

iPowerPrn.of_GetPrinterOrientationString()

Values: DMORIENT_PORTRAIT or DMORIENT_LANDSCAPE as argument of SetPrinterOrientation()

Delphi:

SetPrinterOrientation()

GetPrinterOrientation()

GetPrinterOrientationString()

Values: DMORIENT_PORTRAIT or DMORIENT_LANDSCAPE as argument of SetPrinterOrientation()


PowerPrinter API Reference

Important: If you plan to use the API directly be sure to call the constructor before calling any other function. Please refer to the section below for more details.

dwAbout

Constructor / Destructor

CWin32Prn_CPP_CONSTRUCTOR()

CWin32Prn_CPP_DESTRUCTOR

Unlock (registered users only). It disables the NAG Screen.

dwUnlock

Default Printer

dwGetDefaultPrinterName

dwGetDefaultPrinterPort

dwGetDefaultPrinterDriver

dwSetDefaultPrinter

dwGetPrinterList

dwGetDefaultPrinterEx

dwSetDefaultPrinterEx

DEVMODE -> NB not all attributes are used by the printers. See DEVMODE Structure for more details.

dwGetPrinterOrientation

dwSetPrinterOrientation

dwGetPaperSize

dwSetPaperSize

dwGetSupportedPaperSizeList

dwGetPaperLength

dwSetPaperLength

dwGetPaperWidth

dwSetPaperWidth

dwGetScale

dwSetScale

dwGetCopies

dwSetCopies

dwGetDefaultSource

dwSetDefaultSource

dwGetPaperBinList

dwGetPaperBinListEx

dwGetNamedPaperBinList

dwGetNamedPaperBinListEx

dwGetPrintQuality

dwSetPrintQuality

dwGetColor

dwSetColor

dwGetDuplex

dwSetDuplex

dwGetYResolution

dwSetYResolution

dwGetTTOption

dwSetTTOption

dwGetCollate

dwSetCollate

‘ Printer Access

dwGetPrinterAccess

dwSetPrinterAccess

‘Printer Jobs

dwEnumPrinterJobs

‘List Separator

dwGetListSep

dwSetListSep

‘Item Separator

dwGetItemSep

dwSetItemSep

‘Printer Driver

dwAddPrinterDriver

dwDeletePrinterDriver

dwGetPrinterDrivers

dwGetPrinterDriver

‘Printer Fonts

dwEnumPrinterFonts

dwSetPrinterFont

‘NT Only. Connect to a network printer on the fly

dwAddPrinterConnection

dwDeletePrinterConection

‘ Add either a local or network printer.

dwAddPrinter

dwDeletePrinter

‘Extended error attributes as set by Windows APIs

dwGetExtendedErrorCode

dwGetExtendedErrorMessage

‘PowerDIB Apis. Tell me more about PowerDIB

dwCaptureDesktop

dwPrintTheDIB


Ordering PowerPrinter

We accept orders by either credit cards or the CompuServe Software registration services. PowerPrinter costs only US$ 35 with free upgrades and/or fixes and support. Support is handled mainly by e-mail.

Ordering By Credit Card

Ordering with CompuServe SWREG

As soon as we are notified about your payment we will send you a user name and key that will disable the registration notification screen and grant you the right to use PowerPrinter in your application. The are no runtime fees. This means that you only need a license for every develop using PowerPrinter but can deploy to any number of users and/or applications.

Every time we will update/fix PowerPrinter we will upload it to our web site and inform everybody by email. The upgrades/fixes are free of change to registered customers.

See also

Support


Ordering By Credit Card

For you convenience we have contracted NorthStar Solutions to process any orders that you wish to place with your valid Visa, Discover or MasterCard. They may be contacted for orders only via any of the following methods:

Web: Order online at http://www.nstarsolutions.com . The server support secure transactions and it is highly recommended.

NorthStar has assigned PowerPrinter a product ID that identifies uniquely our product in their database. PowerPrinter ID is 1119. Please use it !

Voice: 	1-800-699-6395 (10:00 a.m. - 10:00 p.m., Eastern Std. Time. Calls from U.S. only)

1-803-699-6395 (10:00 a.m. - 10:00 p.m., Eastern Std. Time. International customers)

Fax:	1-803-699-5465 (Available 24hours. International and business orders encouraged)

E-Mail:

America Online 	STARMAIL

CompuServe	71561,2751

Internet	starmail@aol.com

You may also register with a check or money order. Make them payable to NorthStar Solutions and send them to:

PO Box 25262

Columbia, SC 29224

NorthStar requires the following information:

Credit Card [ ] MasterCard [ ] VISA [ ]  Discover [ ]

Credit Card Number:	_________________________________

Expiration Date:	_________________________________

Name On Card:	_________________________________

E-mail Address:	_________________________________

Billing Address:	_________________________________

_________________________________

_________________________________

NB: NorthStar Solutions does not provide any technical support. The support is provided free of charge by us. Any questions about the status of the shipment of an order, refunds, registration options, product details, technical support, volume discounts, dealer pricing, site licenses, etc., must be directed to DigitalWave Limited, 35 Rue du Kiem, L-8328 Capellen, Luxembourg  or by email to 100441,1136 on CompuServe or digitalwave@compuserve.com on Internet.

Copyright © 1997 by DigitalWave Limited. All rights reserved.


Ordering with CompuServe SWREG

To have the registration fee added to your CompuServe bill

If you are using WinCIM : Click on the traffic line icon and type SWREG

If using a command line utility : type GO SWREG at the ! prompt

and follow the menus.  PowerPrinter registration id is 14063

Address any questions or comments to DigitalWave at 100441,1136 on CompuServe ordigitalwave@compuserve.com .


Sample Applications

A number of sample applications are available. This does not mean that PowerPrinter is limited to the development tools or environment described below. PowerPrinter is a standard 32 Bit DLL and it can be called by any development tool capable of calling external functions, like Centura, Omnis7,  or ORACLE Developer 2000 for example.

Sample applications:

PowerBuilder sample

VisualBasic sample

Delphi sample

PowerPrinter has also been successfully tested with both VB 5 and Delphi 3.


PowerBuilder sample

PowerPrinter comes with a handy pebble (powerprn.pbl) with all the external APIs already declared and a set of functions/procedures to simplify the use of PowerPrinter. Really, it couldn’t be simpler. Moreover, we have also developed a sample application (ppsample.pbl) that shows how to use PowerPrinter from a PowerBuilder application.

NB: You are not obliged to use powerprn.pbl: you can always call PowerPrinter API directly. See PowerPrinter API Reference

To run the sample choose ppsample.pbl as application and add powerprn.pbl to the library list. We suggest that you regenerate both pebbles before running the application especially if you have applied the patches (5.0.01 or 5.0.02).

The relevant code can be found in w_main (ppsample.pbl). It is however important to mention that since we have encapsulated PowerPrinter APIs in a nonvisual user object you have to create it before being able to use it.

// see open event of w_main

// n_PowerPrinter is the nonvisual user object that encapsulates the external APIs

e.g.: nvo_PowerPrn = CREATE n_PowerPrinter

The scope of the variable of type n_PowerPrinter is up to you: it can be global as well as at the window level like the sample application. However, since PowerPrinter has a small memory footprint you can safely declare it at the global level and create/destroy it in the application object open and close event.

To clean memory use:

DESTROY nvo_PowerPrinter

Moreover, powerprn.pbl has also a set of public constants that you can use as argument to PowerPrinter APIs.

E.g.:

nvo_PowerPrn.DMORIENT_PORTRAIT

It can be used as argument to dwSetPrinterOrientation .

Remember to call the dwUnlock API to avoid the ‘registration reminder’ screen.

See also

How To Topics

PowerPrinter API Reference

External Function Declarations


VisualBasic sample

PowerPrinter comes with a VisualBasic sample application which contains as well a VisualBasic class and a module that contain external function declarations and additional VB functions that simplify the use of PowerPrinter.

The class definition is contained in powerprn.cls while the external function declarations can be found in powerprn.bas. Typically, you include these modules into your VisualBasic application and use the functions/procedures provided as methods of the PowerPrn class.

The PowerPrn class call the PowerPrinter API CWin32Prn_CPP_CONSTRUCTOR() and CWin32Prn_CPP_DESTRUCTOR in the class initialize and terminate subroutines.

As you can see in the Form1 declarations (sample application) we have declared iPowerPrn as type PowerPrn

eg:

Dim iPowerPrn As New PowerPrn

and then called the methods using the ClassInstance.Method notation. For instance, to get the default printer name you would code:

Dim sPrinterName As String

sPrinterName = iPowerPrn.GetDefaultPrinterName()

Again, as for other development tools, you are not obliged to use any of the modules supplied to use PowerPrinter. These modules are provided to simplify the use of PowerPrinter but are not *mandatory* by any means – the choice is yours.

Remember to call the dwUnlock API to avoid the ‘registration reminder’ screen.

See also

How To Topics

PowerPrinter API Reference

External Function Declarations


Delphi sample

PowerPrinter comes with a sample application written in Delphi that shows how to use PowerPrinter APIs from your applications. The sample application consists of a unit, powerprn.pas, that contains the declaration of all external APIs and a few handy functions and procedures that simplify the use of PowerPrinter. You can include the unit in your applications and use it as shown in the sample or use the APIs directly – the choice is yours.

To use PowerPrinter unit add ‘powerprn’ to the uses of your unit.

e.g.:

unit aForm;

interface

uses

Windows, Messages, …. powerprn;

Once powerprn has been added to the unit section then you have to create an instance of PowerPrinter by calling the CreatePowerPrinter procedure (declared in powerprn.pas). The sample applications creates the instance in the FormCreate procedure. The instance is removed from memory in the FormClose procedure.

Remember to call the dwUnlock API to avoid the ‘registration reminder’ screen.

See also

How To Topics

PowerPrinter API Reference

External Function Declarations


CWin32Prn_CPP_CONSTRUCTOR()

Description

Create an instance of Cwin32Printer. Make sure that this function is the first PowerPrinter API that you use. The return value is the class handle that must be used for all other API calls. We have provided modules for PowerBuilder, VisualBasic and Delphi that encapsulate the creation/destruction of the CWin32Printer instance. Typically, you call this function when you do not use the modules provided.

The registration reminder is shown only if the constructor is called. This should make it easier for Omnis 7 users since it appears that DLLs in the extension folder are loaded and unloaded at start up.

Argument	Description

none	n/a

Return value

long	class handle. Use it as the first argument of all other API calls.

See also:

CWin32Prn_CPP_DESTRUCTOR

Error Codes


CWin32Prn_CPP_DESTRUCTOR

Description

Free CWin32Printer instance from memory. Call the destructor only with a valid handle obtained with CWin32Prn_CPP_CONSTRUCTOR() .

Argument	Description

Long	instance handle

Return value

n/a

See also:

CWin32Prn_CPP_CONSTRUCTOR()

Error Codes


dwGetDefaultPrinterEx

Description

This function complements the dwGetDefaultPrinterName API which returns the printer name only. This API will returns the printer name, the driver and the port and it has been designed to handle uncommon situations where the same printer name is used more than once -- usually on different ports.

NB: string arguments needs to be pre-allocated before being given by argument to PowerPrinter’s APIs. See How to pass arguments to Powerprinter APIs .

Argument	Description

long	instance handle

string	default printer name. By Reference

string	default printer driver. By Reference

string	default printer port. By Reference

Return value

long	ERR_NO_DEF_PRN if there is no default printer. NO_ERR if OK.

See also:

dwGetDefaultPrinterName

dwGetDefaultPrinterDriver

dwGetDefaultPrinterPort

Error Codes


dwSetDefaultPrinterEx

Description

Set the default printer. This function differs from dwSetDefaultPrinter because you have to supply the driver and port parameters as well. Typically, you have to resort to the API when you have the same printer name over two different ports.

NB: You can print to a file by replacing the port with a file name. However, the recommended method by Microsoft is to pass the filename in the DOCINFO structure to the StartDoc Win 32 API. Unfortunately, 4GLs tools like PowerBuilder do not give access to the DOCINFO structure and hence the only workaround possible is to replace the port name with a file name.

The technique described above works under NT only. Windows 95 users should use dwSetDeafultPrinterPort . This API is supported under both NT and 95. Beware that when using FILE: as port the user is prompted for the file name.

Argument	Description

long	instance handle

string	default printer name

string	default printer driver

string	default printer port

Return value

long	NO_ERR if the new printer could be set as default or ERR_BAD_ARGUMENT if the printer name could not be found in the printer list.

See also

dwSetDefaultPrinter

Error Codes


dwGetDefaultPrinterName

Description

Return the friendly name of the default printer. The name includes as well the server name for network printers.

Argument	Description

long	instance handle

string	the default printer name. By Reference

Return value

long	ERR_NO_DEF_PRN if there is no default printer defined. NO_ERR otherwise.

See also

dwGetDefaultPrinterDriver

dwGetDefaultPrinterPort

dwGetDefaultPrinterEx

Error Codes


dwGetDefaultPrinterPort

Description

Return the printer port for the default printer. The port can be a physical port for local printer or the equivalent name for network printers.

Argument	Description

long	instance handle

string	printer port. By Reference

Return value

long	ERR_NO_DEF_PRN if there is no default printer defined. NO_ERR otherwise.

See also

dwGetDefaultPrinterName

dwGetDefaultPrinterDriver

dwGetDefaultPrinterEx

Error Codes


dwGetDefaultPrinterDriver

Description

Return the driver name used by the default printer. Windows NT uses winspool as driver.

Argument	Description

long	instance handle

string	printer driver. By Reference

Return value

long	ERR_NO_DEF_PRN if there is no default printer defined. NO_ERR otherwise.

See also

dwGetDefaultPrinterName

dwGetDefaultPrinterPort

dwGetDefaultPrinterEx

Error Codes


dwGetPrinterList

Description

Return a list of all printers available. The printer names are separated by semicolumn (;). You have to parse the list to extract printer names.

Argument	Description

long	instance handle

string	printer list buffer. By Reference

Return value

long	the number of printers found.

See also

Error Codes


How to Get/Set the Default Printer

One of the most common tasks is to switch to another printer without popping up the printer selection dialog box. PowerPrinter offers you two APIs to set the default printer. You typically use dwSetDefaultPrinter when you know that the printer name is unique. In other words, the name is not used more than once over different ports. To handle the exception you have to use dwSetDefaultPrinterEx where you supply as well the printer driver and port.

To retrieve the current default printer you typically call dwGetDefaultPrinterName but, again, you can use dwGetDefaultPrinterEx to get the port and driver in one go.

See also

dwGetDefaultPrinterName

dwGetDefaultPrinterDriver

dwGetDefaultPrinterPort

dwGetDefaultPrinterEx

dwSetDefaultPrinter

dwSetDefaultPrinterEx

Error Codes


How to get the list of available printers

The list of available printers can easily be retrieved with dwGetPrinterList . This API returns all printers available in one single string. Printer names are separated by semi-column (;). To extract printer names you have to parse the string for ‘;’ and get the printer name from substrings.

This functionality has been implemented in the Sample Applications . Have a look at the sample code to see how to extract the names.

See also

Error Codes


dwSetDefaultPrinter

Description

Use this function to change the default printer. The printer name must exist.

Argument	Description

long	instance handle

string	printer name

Return value

long	ERR_BAD_ARGUMENT if the printer could not be set, NO_ERR otherwise

See also

dwGetDefaultPrinterName

dwSetDefaultPrinterEx

Error Codes


dwSetPrinterOrientation

Description

This API will allow you to set the orientation of the printer to either PORTRAIT or LANDSCAPE. Not all printers allow you to change orientation.

Argument	Description

long	instance handle

integer	the orientation

Return value

long	ERR_PRN_NOCHANGE if the printer does not allow the change, ERR_BAD_ARGUMENT for unknown values, NO_ERR otherwise.

Values accepted:

DMORIENT_PORTRAIT 	which is equal to 1	(defined in winspool.h)

DMORIENT_LANDSCAPE 	which is equal to 2 	(defined in winspool.h)

See also

dwGetPrinterOrientation

dwSetPrinterOrientation

How to change printer orientation

DEVMODE Structure

DEVMODE Constants

Error Codes


dwGetPrinterOrientation

Description

Return the current orientation of the printer. The printer must be online and, under Windows NT, you need the necessary authority to query printer settings.

Argument	Description

long	instance handle

integer	the orientation

Return value

long	error code. See Error Codes for a description of the error codes.

See also

dwSetPrinterOrientation

How to change printer orientation

DEVMODE Structure

DEVMODE Constants

Error Codes


dwSetPaperSize

Description

Selects the size of the paper to print on. The size can be set to DMPAPER_USER if the length and width of the paper are both set with the dwSetPaperLength and dwSetPaperWidth . Otherwise, the paper size member can be set to one of the predefined values.

Argument	Description

long	instance handle

integer	paper size

Return value

long	error code

See also

dwGetPaperSize

How to change Paper Size

DEVMODE Structure

DEVMODE Constants

Error Codes


dwGetPaperSize

Description

Retrieve the current paper size.

Argument	Description

long	instance handle

integer	paper size. By reference

Return value

long	error code

See also

dwSetPaperSize

How to change Paper Size

DEVMODE Structure

DEVMODE Constants

Error Codes


dwGetPaperLength

Description

Returns the length of the paper specified with dwSetPaperLength . These values, along with all other values that specify a physical length, are in tenths of a millimeter. Please note that this function will return zero for a standard paper size.

Argument	Description

long	instance handle

integer	paper length. By Reference

Return value

long	error code

See also

dwSetPaperLength

DEVMODE Structure

DEVMODE Constants

Error Codes


dwSetPaperLength

Description

Overrides the length of the paper specified by the dwSetPaperSize , either for custom paper sizes or for devices such as dot-matrix printers, which can print on a page of arbitrary length. These values, along with all other values that specify a physical length, are in tenths of a millimeter.

Argument	Description

long	instance handle

integer	paper length

Return value

long	error code

See also

dwGetPaperLength

DEVMODE Structure

DEVMODE Constants

Error Codes


dwGetPaperWidth

Description

Returns the paper width as defined with dwSetPaperWidth . Please note that this function will return zero for a standard paper size.

Argument	Description

long	instance handle

integer	paper width. By reference

Return value

long	error code

See also

dwSetPaperWidth

DEVMODE Structure

DEVMODE Constants

Error Codes


dwSetPaperWidth

Description

Overrides the width of the paper specified by with dwSetPaperSize . These values, along with all other values that specify a physical length, are in tenths of a millimeter.

Argument	Description

long	instance handle

integer	paper size

Return value

long	error code

See also

dwGetPaperWidth

DEVMODE Structure

DEVMODE Constants

Error Codes


dwGetPrintQuality

Description

Return current paper quality. There are four predefined device-independent values: DMRES_HIGH, DMRES_MEDIUM, DMRES_LOW, DMRES_DRAFT. If a positive value is given, it specifies the number of dots per inch (DPI) and is therefore device dependent.

Argument	Description

long	instance handle

integer	print quality. By reference

Return value

long	error code

See also

dwSetPrintQuality

DEVMODE Structure

DEVMODE Constants

Error Codes


dwSetPrintQuality

Description

Specifies the printer resolution. There are four predefined device-independent values: DMRES_HIGH, DMRES_MEDIUM, DMRES_LOW, DMRES_DRAFT

If a positive value is given, it specifies the number of dots per inch (DPI) and is therefore device dependent.

Argument	Description

long	instance handle

integer	print quality

Return value

long	error code

See also

dwGetPrintQuality

DEVMODE Structure

DEVMODE Constants

Error Codes


dwGetScale

Description

Returns the scale factor. Please refer to DEVMODE Structure for a complete description.

Argument	Description

long	instance handle

integer	scale factor. By reference

Return value

long	error code

See also

dwSetScale

DEVMODE Structure

DEVMODE Constants

Error Codes


dwSetScale

Description

Specifies the factor by which the printed output is to be scaled. The apparent page size is scaled from the physical page size by a factor of dmScale/100. For example, a letter-sized page with a dmScale value of 50 would contain as much data as a page of 17- by 22-inches because the output text and graphics would be half their original height and width.

Argument	Description

long	instance handle

integer	scale factor

Return value

long	error code

See also

dwGetScale

DEVMODE Structure

DEVMODE Constants

Error Codes


dwGetCopies

Description

Returns the number of copies as set with dwSetCopies . The device must support multiple-page copies.

Argument	Description

long	instance handle

integer	number of copies. By reference

Return value

long	error code

See also

dwSetCopies

DEVMODE Structure

DEVMODE Constants

Error Codes


dwSetCopies

Description

Set the number of copies printed if the device supports multiple-page copies.

Argument	Description

long	instance handle

integer	number of copies

Return value

long	error code

See also

dwGetCopies

DEVMODE Structure

DEVMODE Constants

Error Codes


dwGetDefaultSource

Description

Get the printer paper source (or bin). The list of paper bins can be retrieved with dwGetPaperBinList or dwGetNamedPaperBinList .

Argument	Description

long	instance handle

integer	paper bin

Return value

long	error code

See also

dwSetDefaultSource

DEVMODE Structure

DEVMODE Constants

Error Codes


dwSetDefaultSource

Description

Set the default printer paper source (or bin). The list of paper sources can be retrieved with dwGetPaperBinList .

Argument	Description

long	instance handle

integer	paper source

Return value

long	error code

See also

dwGetDefaultSource

DEVMODE Structure

DEVMODE Constants

Error Codes


dwGetColor

Description

Retrieve current settings for color printers. The value can be either DMCOLOR_COLOR or DMCOLOR_MONOCHROME.

Argument	Description

long	instance handle

integer	color setting. By reference

Return value

long	error code

See also

dwSetColor

DEVMODE Structure

DEVMODE Constants

Error Codes


dwSetColor

Description

Switches between color and monochrome on color printers. Following are the possible values: DMCOLOR_COLOR or DMCOLOR_MONOCHROME

Argument	Description

long	instance handle

integer	color setting

Return value

long	error code

See also

dwGetColor

DEVMODE Structure

DEVMODE Constants

Error Codes


dwGetDuplex

Description

Return duplex settings.  Following are the possible values: DMDUP_SIMPLEX, DMDUP_HORIZONTAL, DMDUP_VERTICAL.

Argument	Description

long	instance handle

integer	duplex settings. By reference

Return value

long	error code

See also

dwSetDuplex

DEVMODE Structure

DEVMODE Constants

Error Codes


dwSetDuplex

Description

Selects duplex or double-sided printing for printers capable of duplex printing. Following are the possible values: DMDUP_SIMPLEX, DMDUP_HORIZONTAL, DMDUP_VERTICAL.

Argument	Description

long	instance handle

integer	duplex setting

Return value

long	error code

See also

dwGetDuplex

DEVMODE Structure

DEVMODE Constants

Error Codes


dwGetYResolution

Description

Retrieves the y-resolution, in dots per inch, of the printer.

Argument	Description

long	instance handle

integer	Y resolution. By reference

Return value

long	error code

See also

dwSetYResolution

DEVMODE Structure

DEVMODE Constants

Error Codes


dwSetYResolution

Description

Specifies the y-resolution, in dots per inch, of the printer. If the printer initializes this member, the dmPrintQuality member specifies the x-resolution, in dots per inch, of the printer.

Argument	Description

long	instance handle

integer	Y resolution

Return value

long	error code

See also

dwGetYResolution

DEVMODE Structure

DEVMODE Constants

Error Codes


dwGetTTOption

Description

Retrieves how TrueType® fonts should be printed. This member can be one of the following values:

Value	Meaning

DMTT_BITMAP	Prints TrueType fonts as graphics. This is the default action for dot-matrix printers.

DMTT_DOWNLOAD	Downloads TrueType fonts as soft fonts. This is the default action for Hewlett-Packard printers that use Printer Control Language (PCL).

DMTT_SUBDEV	Substitute device fonts for TrueType fonts. This is the default action for PostScript® printers.

Argument	Description

long	instance handle

integer	true type option. By reference

Return value

long	error code

See also

dwSetTTOption

DEVMODE Structure

DEVMODE Constants

Error Codes


dwSetTTOption

Description

Specifies how TrueType® fonts should be printed. This member can be one of the following values:

Value	Meaning

DMTT_BITMAP	Prints TrueType fonts as graphics. This is the default action for dot-matrix printers.

DMTT_DOWNLOAD	Downloads TrueType fonts as soft fonts. This is the default action for Hewlett-Packard printers that use Printer Control Language (PCL).

DMTT_SUBDEV	Substitute device fonts for TrueType fonts. This is the default action for PostScript® printers.

Argument	Description

long	instance handle

integer	true type option

Return value

long	error code

See also

dwGetTTOption

DEVMODE Structure

DEVMODE Constants

Error Codes


dwGetCollate

Description

Retrieve Collate option. Collate is used to send data to the printer only once when printing multiple copies.

Argument	Description

long	instance handle

integer	collate option. By reference

Return value

long	error code

See also

dwSetCollate

DEVMODE Structure

DEVMODE Constants

Error Codes


dwSetCollate

Description

Specifies whether collation should be used when printing multiple copies. This member can be one of the following values:

Value	Meaning

DMCOLLATE_TRUE	Collate when printing multiple copies.

DMCOLLATE_FALSE	Do not collate when printing multiple copies.

Using DMCOLLATE_TRUE provides faster, more efficient output for collation, since the data is sent to the device driver just once, no matter how many copies are required. The printer is told to simply print the page again.

Argument	Description

long	instance handle

integer	collate option

Return value

long	error code

See also

dwGetCollate

DEVMODE Structure

DEVMODE Constants

Error Codes


dwAbout

Description

To show PowerPrinter ‘About’ Dialog Box.

Argument	Description

none	n/a

Return value

none	n/a


Limitations and Operating System Differences


How to change Paper Size

Selects the size of the paper to print on. This member can be set to zero if the length and width of the paper are both set by the dmPaperLength and dmPaperWidth members. Otherwise, the dmPaperSize member can be set to one of the following predefined values:

Value	Meaning

DMPAPER_LETTER	Letter, 8 1/2- by 11-inches

DMPAPER_LEGAL	Legal, 8 1/2- by 14-inches

DMPAPER_A4	A4 Sheet, 210- by 297-millimeters

DMPAPER_CSHEET	C Sheet, 17- by 22-inches

DMPAPER_DSHEET	D Sheet, 22- by 34-inches

DMPAPER_ESHEET	E Sheet, 34- by 44-inches

DMPAPER_LETTERSMALL	Letter Small, 8 1/2- by 11-inches

DMPAPER_TABLOID	Tabloid, 11- by 17-inches

DMPAPER_LEDGER	Ledger, 17- by 11-inches

DMPAPER_STATEMENT	Statement, 5 1/2- by 8 1/2-inches

DMPAPER_EXECUTIVE	Executive, 7 1/4- by 10 1/2-inches

DMPAPER_A3	A3 sheet, 297- by 420-millimeters

DMPAPER_A4SMALL	A4 small sheet, 210- by 297-millimeters

DMPAPER_A5	A5 sheet, 148- by 210-millimeters

DMPAPER_B4	B4 sheet, 250- by 354-millimeters

DMPAPER_B5	B5 sheet, 182- by 257-millimeter paper

DMPAPER_FOLIO	Folio, 8 1/2- by 13-inch paper

DMPAPER_QUARTO	Quarto, 215- by 275-millimeter paper

DMPAPER_10X14	10- by 14-inch sheet

DMPAPER_11X17	11- by 17-inch sheet

DMPAPER_NOTE	Note, 8 1/2- by 11-inches

DMPAPER_ENV_9	#9 Envelope, 3 7/8- by 8 7/8-inches

DMPAPER_ENV_10	#10 Envelope, 4 1/8- by 9 1/2-inches

DMPAPER_ENV_11	#11 Envelope, 4 1/2- by 10 3/8-inches

DMPAPER_ENV_12	#12 Envelope, 4 3/4- by 11-inches

DMPAPER_ENV_14	#14 Envelope, 5- by 11 1/2-inches

DMPAPER_ENV_DL	DL Envelope, 110- by 220-millimeters

DMPAPER_ENV_C5	C5 Envelope, 162- by 229-millimeters

DMPAPER_ENV_C3	C3 Envelope,  324- by 458-millimeters

DMPAPER_ENV_C4	C4 Envelope,  229- by 324-millimeters

DMPAPER_ENV_C6	C6 Envelope,  114- by 162-millimeters

DMPAPER_ENV_C65	C65 Envelope, 114- by 229-millimeters

DMPAPER_ENV_B4	B4 Envelope,  250- by 353-millimeters

DMPAPER_ENV_B5	B5 Envelope,  176- by 250-millimeters

DMPAPER_ENV_B6	B6 Envelope,  176- by 125-millimeters

DMPAPER_ENV_ITALY	Italy Envelope, 110- by 230-millimeters

DMPAPER_ENV_MONARCH	Monarch Envelope, 3 7/8- by 7 1/2-inches

DMPAPER_ENV_PERSONAL	6 3/4 Envelope, 3 5/8- by 6 1/2-inches

DMPAPER_FANFOLD_US	US Std Fanfold, 14 7/8- by 11-inches

DMPAPER_FANFOLD_STD_GERMAN	German Std Fanfold, 8 1/2- by 12-inches

DMPAPER_FANFOLD_LGL_GERMAN	German Legal Fanfold, 8 1/2- by 13-inches

See also

dwGetPaperSize

dwSetPaperSize

dwGetPaperLength

dwSetPaperLength

dwGetPaperWidth

dwSetPaperWidth

DEVMODE Structure

DEVMODE Constants

Error Codes


DEVMODE Structure

The DEVMODE data structure contains information about the device initialization and environment of a printer. You have access to almost all its members through the dwSet and dwGet PowerPrinter APIs. Not all members are meaningful for printing devices.

From the Microsoft Developer Network CD:

dmOrientation

Selects the orientation of the paper. This member can be either DMORIENT_PORTRAIT (1) or DMORIENT_LANDSCAPE (2).

dmPaperSize

Selects the size of the paper to print on. This member can be set to DMPAPER_USER

 if the length and width of the paper are both set by the dmPaperLength and dmPaperWidth members. Otherwise, the dmPaperSize member can be set to one of the predefined values. See How to change Paper Size for the complete list.

dmPaperLength

Overrides the length of the paper specified by the dmPaperSize member, either for custom paper sizes or for devices such as dot-matrix printers, which can print on a page of arbitrary length. These values, along with all other values in this structure that specify a physical length, are in tenths of a millimeter.

dmPaperWidth

Overrides the width of the paper specified by the dmPaperSize member.

dmScale

Specifies the factor by which the printed output is to be scaled. The apparent page size is scaled from the physical page size by a factor of dmScale/100. For example, a letter-sized page with a dmScale value of 50 would contain as much data as a page of 17- by 22-inches because the output text and graphics would be half their original height and width.

dmCopies

Selects the number of copies printed if the device supports multiple-page copies.

dmDefaultSource

Reserved; must be zero.

dmPrintQuality

Specifies the printer resolution. There are four predefined device-independent values:

DMRES_HIGH
DMRES_MEDIUM
DMRES_LOW
DMRES_DRAFT

If a positive value is given, it specifies the number of dots per inch (DPI) and is therefore device dependent.

dmColor

Switches between color and monochrome on color printers. Following are the possible values:

DMCOLOR_COLOR
DMCOLOR_MONOCHROME

dmDuplex

Selects duplex or double-sided printing for printers capable of duplex printing. Following are the possible values:

DMDUP_SIMPLEX
DMDUP_HORIZONTAL
DMDUP_VERTICAL

dmYResolution

Specifies the y-resolution, in dots per inch, of the printer. If the printer initializes this member, the dmPrintQuality member specifies the x-resolution, in dots per inch, of the printer.

dmTTOption

Specifies how TrueType® fonts should be printed. This member can be one of the following values:

Value	Meaning

DMTT_BITMAP	Prints TrueType fonts as graphics. This is the default action for dot-matrix printers.

DMTT_DOWNLOAD	Downloads TrueType fonts as soft fonts. This is the default action for Hewlett-Packard   printers that use Printer Control Language (PCL).

DMTT_SUBDEV	Substitute device fonts for TrueType fonts. This is the default action for PostScript® printers.

dmCollate

Specifies whether collation should be used when printing multiple copies. (This member is ignored unless the printer driver indicates support for collation by setting the dmFields member to DM_COLLATE.) This member can be be one of the following values:

Value	Meaning

DMCOLLATE_TRUE	Collate when printing multiple copies.

DMCOLLATE_FALSE	Do not collate when printing multiple copies.

Additional members not used by printer drivers.

dmLogPixels

Specifies the number of pixels per logical inch. Printer drivers do not use this member.

dmBitsPerPel

Specifies the color resolution, in bits per pixel, of the display device (for example: 4 bits for 16 colors, 8 bits for 256 colors, or 16 bits for 65536 colors). Display drivers use this member, for example, in the ChangeDisplaySettings function. Printer drivers do not use this member.

dmPelsWidth

Specifies the width, in pixels, of the visible device surface. Display drivers use this member, for example, in the ChangeDisplaySettings function. Printer drivers do not use this member.

dmPelsHeight

Specifies the height, in pixels, of the visible device surface. Display drivers use this member, for example, in the ChangeDisplaySettings function. Printer drivers do not use this member.

dmDisplayFlags

Specifies the device's display mode. This member can be one of the following values:

Value	Meaning

DM_GRAYSCALE	Specifies that the display is a noncolor device. If this flag is not set, color is assumed.

DM_INTERLACED	Specifies that the display mode is interlaced. If the flag is not set, noninterlaced is assumed.

Display drivers use this member, for example, in the ChangeDisplaySettings function. Printer drivers do not use this member.

dmDisplayFrequency

Specifies the frequency, in hertz (cycles per second), of the display device in a particular mode. This value is also known as the display device's vertical refresh rate. Display drivers use this member. It is used, for example, in the ChangeDisplaySettings function. Printer drivers do not use this member.

When you call the EnumDisplaySettings function, the dmDisplayFrequency member may return with the value 0 or 1. These values represent the display hardware's default refresh rate. This default rate is typically set by switches on a display card or computer motherboard, or by a configuration program that does not use Win32 display functions such as ChangeDisplaySettings.


License Agreement

Please read carefully the following terms and conditions before using this software. Your use of this software indicates your acceptance of this license agreement and warranty.

We expect you to pay a license for each developer using PowerPrinter. Applications may them be deployed to any number of users with no extra fees.

Registered Version

One registered copy of PowerPrinter may either be used by a single developer who uses the software personally on one or more computers, or installed on a single workstation used non simultaneously by multiple people, but not both.

You may access the registered version of PowerPrinter through a network, provided that you have obtained individual licenses for the software covering all developers workstations that will access the software through the network.

There are no runtime royalties.

Disclaimer of Warranty

THIS SOFTWARE AND THE ACCOMPANYING FILES ARE SOLD "AS IS" AND WITHOUT WARRANTIES AS TO PERFORMANCE OF MERCHANTABILITY OR ANY OTHER WARRANTIES WHETHER EXPRESSED OR IMPLIED.


Support

Technical support is available at no charge by sending electronic mail to:

100441,1136 on CompuServe,

or 	support@digitalw.com on Internet,

If you do not have access to the Internet you can contact us by fax on the following number:

Fax:	+352.305.955

How to Report Problems

When reporting problems, please include the following information:

-	PowerPrinter version

-	If the problem is reproducible, then please indicate how,

-	Operating System,

No waiting on the phone line: sends us a brief description of your problem and we will get back to you at the speed of light !.


How to get rid of the NAG Screen

PowerPrinter is not freeware. To get rid of the registration reminder screen you have to purchase a developer license (US$ 35). You will then receive a user name and key that you will use to unlock PowerPrinter.

Please refer to the dwUnlock API for additional details.

See also

dwUnlock

Ordering PowerPrinter

License Agreement


dwUnlock

Description

This API unlocks PowerPrinter. In other words, you don’t get the registration reminder screen anymore when PowerPrinter gets unloaded. Please note that the key is not stored permanently like many commercial applications. This basically means that you have to place a call to dwUnlock in you application. We recommend to place the call to dwUnlock just after having called CWin32Prn_CPP_CONSTRUCTOR()  API so that you will not have to bother anymore with the registration reminder.

Omnis7 Users: do not place powerprn.dll in the extensions folder because the dll can be unloaded before you have the chance to call dwUnlock and get the registration remainder message.

Contact us for your user name and key if you haven’t received one. This applies to all registered users only, of course.

Argument	Description

string	user name as it was sent to you upon registration

long	your key as it was sent to you upon registration

Return value

long	1 if successful. A message box pops up if the key does not match.

Example

string	ls_UserName

long	ll_Key

ls_UserName = “My Name”

ll_Key = 12345

dwUnlock(ls_UserName, ll_key)


Error Codes

The following is a table of error codes as returned by PowerPrinter APIs.

NO_ERR	1	//  no error

ERR_BAD_ARGUMENT	-1	// bad argument given to function

ERR_BUFFER_2SMALL	-2	// buffer not large enough

ERR_NO_DEF_PRN	-3	// no default printer

ERR_NO_DEF_PORT	-4	// no default printer port (v1.1)

ERR_NO_DEF_DRIVER	-5	// no default printer driver (v1.1)

ERR_BUFFER_EMPTY	-6	// given argument is empty ! (v1.1)

ERR_NULL_POINTER	-7	// null pointer eceived while expecting an argument (v1.1)

ERR_PRN_OPEN	-100	// Cannot get the printer -- access problem ?. Watch out NT users

ERR_PRN_GET	-101	// GetPrinter failed to return buffer size

ERR_GLOBAL_ALLOC	-102	// GlobalAlloc failed

ERR_GLOBAL_LOCK	-103	// GlobalLock failed

ERR_PRINT_INFO2	-104	// Cannot fill in PRINT_INFO_2 structure

ERR_PRN_NOCHANGE	-105	// Printer does not support change

ERR_UPDT_DEVMODE	-106	// Cannot update driver-dependent part of devmode

ERR_PRN_SET	-107	// SetPrinter Failed

ERR_ATTR_UNKNOWN	-108	// Unknown Attribute

ERR_DEVMODE_ISNULL	-109	// GetPrinter API failed -- even if ret code was OK !

ERR_NOT_IMPLEMENTED	-110	// API not implmemented (v1.1)

ERR_ADD_PRINTER	-111	// AddPrinter API failed (v1.1)

ERR_ADD_PRNCONN	-112	// AddPrinterConnection API failed (v1.1)

ERR_DEL_PRNCONN	-113	// DeletePrinterConnection API failed (v1.1)

ERR_DEL_PRINTER	-114	// DeletePrinter API failed (v1.1)

ERR_ADD_DRIVER	-115	// AddAPrinterDriver failed (v1.1)

ERR_DEL_DRIVER	-116	// DelAPrinterDriver failed (v1.1)

ERR_LOCAL_ALLOC	-117	// LocalAlloc failed (v1.1)

ERR_ENUM_NO_DRV	-118	// EnumDrivers returned zero (v1.1)

ERR_NOTHING_2DO	-119	// Nothing to do (v1.1). Eg no print jobs

ERR_ENUM_JOBS1	-120	// EnumJobs (step 1) failed (v1.1)

ERR_ENUM_JOBS2	-121	// EnumJobs (step 2) failed (v1.1)

ERR_WIN95_SETDEFPRNEX 	-122	// SetDefaultPrinterEx failed under Win 95 (v1.1)

ERR_NOLOAD_POWERDIB	-123	// Cannot load PowerDIB (v1.1)

ERR_NOLOAD_FUNCTION 	-124	// Cannot Load function. This should never happen ! (v1.1)

ERR_BAD_DC	-125	// Bad device context argument (v1.1)

ERR_CREATE_FONT	-126	// Could not create the font (v1.1)

ERR_COPY_WINDOW	-127	// Could not copy window (v1.1)

ERR_FATAL_ERROR	-128	// Fatal Error. Us dwGetExtendedErrorCode (v1.1)


How to pass arguments to Powerprinter APIs

When calling an external function that returns a string (by reference) you have to pre-allocate a buffer large enough to contain the data value.

PowerBuilder

string lsPrn

long i

lsPrn = space(255)	// allocate buffer

// this_hdl is the handle returned by the constructor

i = dwGetDefaultPrinterName (this_hdl, lsPrn)

the corresponding external function declaration is declared as:

Function  long dwGetDefaultPrinterName (ulong hdl, REF string sDefaultPprinter) Library "powerprn.dll"

For Setxxx APIs, there is no need to use the REF keyword.

VisualBasic

Dim PrnName As String

Dim Ret As Long

PrnName = String(200,0)	‘ allocate buffer

Ret = dwGetDefaultPrinterName(hdl, PrnName)

the corresponding external function declaration is declared as:

Declare Function  dwGetDefaultPrinterName Lib "powerprn.dll" (ByVal hdl As Long, ByVal sDefaultPprinter as String)  As Long

Delphi

When calling external APIs that return a string you can either allocate a buffer with StrAlloc or create an array of char type.

Var

pDefPrinterName:pChar;

pBuffer: array ..256 of char;

Ret : LongInt;

begin

pDefPrinterName := pBuffer;

Ret := dwgetDefaultPrinterName(hdl, pDefPrinterName);

etc

end;

PowerPrinter APIs uses either long or integer as arguments.

Long	-> 32 bit value

Integer	-> 16 Bit value

See also

PowerPrinter API Reference

External Function Declarations


External Function Declarations

Follow the links to find the correct syntax for your favorite development tool.

PowerBuilder External Function Declarations

VisualBasic External Function Declarations

Delphi External Function Declarations


PowerBuilder External Function Declarations

// constructor & destructor

function ulong CWin32Prn_CPP_CONSTRUCTOR() library "powerprn.dll"

subroutine CWin32Prn_CPP_DESTRUCTOR(ulong hdl) library "powerprn.dll"

// default printer API

Function  long dwGetDefaultPrinterName (ulong hdl, ref string sDefaultPprinter) Library "powerprn.dll"

Function  long dwGetPrinterList (ulong hdl, ref string sDefaultPprinter) Library "powerprn.dll"

Function Long dwGetDefaultPrinterPort (ulong hdl, ref string sDefaultPprinter) Library "powerprn.dll"

Function Long dwGetDefaultPrinterDriver (ulong hdl, ref string sDefaultPprinter) Library "powerprn.dll"

Function Long dwSetDefaultPrinter (ulong hdl, string sDefaultPprinter) Library "powerprn.dll"

Function Long dwGetDefaultPrinterEx (ulong hdl, ref string sPrinterName, ref string PrinterDriver, ref string printerport) Library "powerprn.dll"

Function Long dwSetDefaultPrinterEx (ulong hdl, string sPrinterName, string PrinterDriver, string printerport) Library "powerprn.dll"

// orientation

Function Long dwGetPrinterOrientation(ulong hdl, ref int iPrnOrientation) library "powerprn.dll"

Function Long dwSetPrinterOrientation(ulong hdl, int iPrnOrientation) library "powerprn.dll"

// int paper size

Function Long dwGetPaperSize(ulong hdl, ref int iPaperSize) library "powerprn.dll"

Function Long dwSetPaperSize(ulong hdl, int iPaperSize) library "powerprn.dll"

// int paper Length

Function Long dwGetPaperLength(ulong hdl, ref int iPaperLength) library "powerprn.dll"

Function Long dwSetPaperLength(ulong hdl, int iPaperLength) library "powerprn.dll"

// int paper Width

Function Long dwGetPaperWidth(ulong hdl, ref int iPaperWidth) library "powerprn.dll"

Function Long dwSetPaperWidth(ulong hdl, int iPaperWidth) library "powerprn.dll"

// Scale

Function Long dwGetScale(ulong hdl, ref int iScale) library "powerprn.dll"

Function Long dwSetScale(ulong hdl, int iScale) library "powerprn.dll"

// Copies

Function Long dwGetCopies(ulong hdl, ref int iCopies) library "powerprn.dll"

Function Long dwSetCopies(ulong hdl, int iCopies) library "powerprn.dll"

// Default Source

Function Long dwGetDefaultSource(ulong hdl, ref int iSource) library "powerprn.dll"

Function Long dwSetDefaultSource(ulong hdl, int iSource) library "powerprn.dll"

// int  dmPrintQuality

Function Long dwGetPrintQuality(ulong hdl, ref int iPrintQuality) library "powerprn.dll"

Function Long dwSetPrintQuality(ulong hdl, int iPrintQuality) library "powerprn.dll"

// Color

Function Long dwGetColor(ulong hdl, ref int iColor) library "powerprn.dll"

Function Long dwSetColor(ulong hdl, int iColor) library "powerprn.dll"

// Duplex

Function Long dwGetDuplex(ulong hdl, ref int iDuplex) library "powerprn.dll"

Function Long dwSetDuplex(ulong hdl, int iDuplex) library "powerprn.dll"

// YResolution

Function Long dwGetYResolution(ulong hdl, ref int iYResolution) library "powerprn.dll"

Function Long dwSetYResolution(ulong hdl, int iYResolution) library "powerprn.dll"

// TTOption

Function Long dwGetTTOption(ulong hdl, ref int iTTOption) library "powerprn.dll"

Function Long dwSetTTOption(ulong hdl, int iTTOption) library "powerprn.dll"

// Collate

Function Long dwGetCollate(ulong hdl, ref int iCollate) library "powerprn.dll"

Function Long dwSetCollate(ulong hdl, int iCollate) library "powerprn.dll"

// various

subroutine dwAbout() library "powerprn.dll"

function long dwUnlock(string sRegisteredUser, long lKey) library "powerprn.dll"

Function  long dwGetPaperBinList(ulong hdl, ref string sBinList) Library "powerprn.dll"

Function  long dwGetNamedPaperBinList(ulong hdl, ref string sBinList) Library "powerprn.dll"

Function Long dwGetSupportedPaperSizeList(ulong hdl, ref string szPageSizeList) Library "powerprn.dll"


VisualBasic External Function Declarations

'constructor and destructor

Declare Function CWin32Prn_CPP_CONSTRUCTOR Lib "powerprn.dll" () As Long

Declare Sub CWin32Prn_CPP_DESTRUCTOR Lib "powerprn.dll" (ByVal hdl As Long)

' default printer

Declare Function dwGetDefaultPrinterName Lib "powerprn.dll" (ByVal hdl As Long, ByVal szPrtr As String) As Long

Declare Function dwGetDefaultPrinterDriver Lib "powerprn.dll" (ByVal hdl As Long, ByVal szDriver As String) As Long

Declare Function dwGetDefaultPrinterPort Lib "powerprn.dll" (ByVal hdl As Long, ByVal szPort As String) As Long

Declare Function dwSetDefaultPrinter Lib "powerprn.dll" (ByVal hdl As Long, ByVal szPrinterName As String) As Long

' printer list

Declare Function dwGetPrinterList Lib "powerprn.dll" (ByVal hdl As Long, ByVal szPrtr As String) As Long

' extended set: printer name, driver, port

Declare Function dwGetDefaultPrinterEx Lib "powerprn.dll" (ByVal hdl As Long, ByVal szPrinterName As String, ByVal szPrinterDriver As String, ByVal szPrinterPort As String) As Long

Declare Function dwSetDefaultPrinterEx Lib "powerprn.dll" (ByVal hdl As Long, szPrinterName As String, szPrinterDriver As String, szPrinterPort As String) As Long

' DEVMODE

Declare Function dwSetPrinterOrientation Lib "powerprn.dll" (ByVal hdl As Long, ByVal iPrinterOrientation As Integer) As Long

Declare Function dwGetPrinterOrientation Lib "powerprn.dll" (ByVal hdl As Long, ByRef iPrinterOrientation As Integer) As Long

' byval paper size

Declare Function dwGetPaperSize Lib "powerprn.dll" (ByVal hdl As Long, ByRef iPaperSize As Integer) As Long

Declare Function dwSetPaperSize Lib "powerprn.dll" (ByVal hdl As Long, ByVal iPaperSize As Integer) As Long

' byval paper Length

Declare Function dwGetPaperLength Lib "powerprn.dll" (ByVal hdl As Long, ByRef iPaperLength As Integer) As Long

Declare Function dwSetPaperLength Lib "powerprn.dll" (ByVal hdl As Long, ByVal iPaperLength As Integer) As Long

' byval paper Width

Declare Function dwGetPaperWidth Lib "powerprn.dll" (ByVal hdl As Long, ByRef iPaperWidth As Integer) As Long

Declare Function dwSetPaperWidth Lib "powerprn.dll" (ByVal hdl As Long, ByVal iPaperWidth As Integer) As Long

' Scale

Declare Function dwGetScale Lib "powerprn.dll" (ByVal hdl As Long, ByRef iScale As Integer) As Long

Declare Function dwSetScale Lib "powerprn.dll" (ByVal hdl As Long, ByVal iScale As Integer) As Long

' Copies

Declare Function dwGetCopies Lib "powerprn.dll" (ByVal hdl As Long, ByRef iCopies As Integer) As Long

Declare Function dwSetCopies Lib "powerprn.dll" (ByVal hdl As Long, ByVal iCopies As Integer) As Long

' Default Source

Declare Function dwGetDefaultSource Lib "powerprn.dll" (ByVal hdl As Long, ByRef iSource As Integer) As Long

Declare Function dwSetDefaultSource Lib "powerprn.dll" (ByVal hdl As Long, ByVal iSource As Integer) As Long

' byval  dmPrintQuality

Declare Function dwGetPrintQuality Lib "powerprn.dll" (ByVal hdl As Long, ByRef iPrintQuality As Integer) As Long

Declare Function dwSetPrintQuality Lib "powerprn.dll" (ByVal hdl As Long, ByVal iPrintQuality As Integer) As Long

' Color

Declare Function dwGetColor Lib "powerprn.dll" (ByVal hdl As Long, ByRef iColor As Integer) As Long

Declare Function dwSetColor Lib "powerprn.dll" (ByVal hdl As Long, ByVal iColor As Integer) As Long

' Duplex

Declare Function dwGetDuplex Lib "powerprn.dll" (ByVal hdl As Long, ByRef iDuplex As Integer) As Long

Declare Function dwSetDuplex Lib "powerprn.dll" (ByVal hdl As Long, ByVal iDuplex As Integer) As Long

' YResolution

Declare Function dwGetYResolution Lib "powerprn.dll" (ByVal hdl As Long, ByRef iYResolution As Integer) As Long

Declare Function dwSetYResolution Lib "powerprn.dll" (ByVal hdl As Long, ByVal iYResolution As Integer) As Long

' TTOption

Declare Function dwGetTTOption Lib "powerprn.dll" (ByVal hdl As Long, ByRef iTTOption As Integer) As Long

Declare Function dwSetTTOption Lib "powerprn.dll" (ByVal hdl As Long, ByVal iTTOption As Integer) As Long

' Collate

Declare Function dwGetCollate Lib "powerprn.dll" (ByVal hdl As Long, ByRef iCollate As Integer) As Long

Declare Function dwSetCollate Lib "powerprn.dll" (ByVal hdl As Long, ByVal iCollate As Integer) As Long

' various

Declare Sub dwAbout Lib "powerprn.dll" ()

Declare Function dwUnlock Lib "powerprn.dll" (ByVal RegUser As String, ByVal Key As Long) As Long

Declare Function dwGetPaperBinList Lib "powerprn.dll" (ByVal hdl As Long, ByVal szPaperList As String) As Long

Declare Function dwGetNamedPaperBinList Lib "powerprn.dll" (ByVal hdl As Long, ByVal szPaperList As String) As Long

Declare Function dwGetSupportedPaperSizeList Lib "powerprn.dll" (ByVal hdl As Long, ByVal szPaperSizeList As String) As Long


Delphi External Function Declarations

function CWin32Prn_CPP_CONSTRUCTOR : longint; stdcall; external 'powerprn.dll';

Procedure CWin32Prn_CPP_DESTRUCTOR (hdl:Longint) ; stdcall; external 'powerprn.dll';

function dwGetDefaultPrinterName (hdl:LongInt; pPrnName:pChar):longint; stdcall; external 'powerprn.dll';

function dwGetDefaultPrinterPort (hdl:LongInt; pPrnPort:pChar):longint; stdcall; external 'powerprn.dll';

function dwGetDefaultPrinterDriver (hdl:LongInt; pPrnDriver:pChar):longint; stdcall; external 'powerprn.dll';

function dwGetPrinterList (hdl:LongInt; szPrtr:pChar):longint; stdcall; external 'powerprn.dll'

function dwSetDefaultPrinter (hdl:LongInt; szPrinterName:pChar):longint; stdcall; external 'powerprn.dll'

function dwGetDefaultPrinterEx (hdl:LongInt; szPrinterName, szPrinterDriver, szPrinterPort:pChar):longint; stdcall; external 'powerprn.dll'

function dwSetDefaultPrinterEx (hdl:LongInt; const szPrinterName, szPrinterDriver, szPrinterPort:pChar):longint; stdcall; external 'powerprn.dll'

// short orientation

function dwGetPrinterOrientation(hdl:LongInt; var iOrient:SmallInt):longint; stdcall; external 'powerprn.dll';

function dwSetPrinterOrientation(hdl:LongInt; iOrient:SmallInt):longint; stdcall; external 'powerprn.dll';

// short paper size

function dwGetPaperSize(hdl:longint; var iPaperSize:smallint) :longint; stdcall; external 'powerprn.dll'

function dwSetPaperSize(hdl:longint; iPaperSize:smallint) :longint; stdcall; external 'powerprn.dll'

// short paper Length

function dwGetPaperLength(hdl:longint; var iPaperLength:smallint) :longint; stdcall; external 'powerprn.dll'

function dwSetPaperLength(hdl:longint; iPaperLength:smallint) :longint; stdcall; external 'powerprn.dll'

// short paper Width

function dwGetPaperWidth(hdl:longint; var iPaperWidth:smallint) :longint; stdcall; external 'powerprn.dll'

function dwSetPaperWidth(hdl:longint; iPaperWidth:smallint) :longint; stdcall; external 'powerprn.dll'

// Scale

function dwGetScale(hdl:longint; var iScale:smallint) :longint; stdcall; external 'powerprn.dll'

function dwSetScale(hdl:longint; iScale:smallint) :longint; stdcall; external 'powerprn.dll'

// Copies

function dwGetCopies(hdl:longint; var iCopies:smallint) :longint; stdcall; external 'powerprn.dll'

function dwSetCopies(hdl:longint; iCopies:smallint) :longint; stdcall; external 'powerprn.dll'

// Default Source

function dwGetDefaultSource(hdl:longint; var iSource:smallint) :longint; stdcall; external 'powerprn.dll'

function dwSetDefaultSource(hdl:longint; iSource:smallint) :longint; stdcall; external 'powerprn.dll'

// short  dmPrintQuality

function dwGetPrintQuality(hdl:longint; var iPrintQuality:smallint) :longint; stdcall; external 'powerprn.dll'

function dwSetPrintQuality(hdl:longint; iPrintQuality:smallint) :longint; stdcall; external 'powerprn.dll'

// Color

function dwGetColor(hdl:longint; var iColor:smallint) :longint; stdcall; external 'powerprn.dll'

function dwSetColor(hdl:longint; iColor:smallint) :longint; stdcall; external 'powerprn.dll'

// Duplex

function dwGetDuplex(hdl:longint; var iDuplex:smallint) :longint; stdcall; external 'powerprn.dll'

function dwSetDuplex(hdl:longint; iDuplex:smallint) :longint; stdcall; external 'powerprn.dll'

// YResolution

function dwGetYResolution(hdl:longint; var iYResolution:smallint) :longint; stdcall; external 'powerprn.dll'

function dwSetYResolution(hdl:longint; iYResolution:smallint) :longint; stdcall; external 'powerprn.dll'

// TTOption

function dwGetTTOption(hdl:longint; var iTTOption:smallint) :longint; stdcall; external 'powerprn.dll'

function dwSetTTOption(hdl:longint; iTTOption:smallint) :longint; stdcall; external 'powerprn.dll'

// Collate

function dwGetCollate(hdl:longint; var iCollate:smallint) :longint; stdcall; external 'powerprn.dll'

function dwSetCollate(hdl:longint; iCollate:smallint) :longint; stdcall; external 'powerprn.dll'

Procedure dwAbout ; stdcall; external 'powerprn.dll';

function dwUnlock (sregUser:pChar; lKey:LOngInt): longint; stdcall; external 'powerprn.dll'

Function dwGetPaperBinList (hdl:LongInt; szPaperList:pChar): longint; stdcall; external 'powerprn.dll'

Function dwGetNamedPaperBinList (hdl:LongInt; szPaperList:pChar) : longint; stdcall; external 'powerprn.dll'

Function dwGetSupportedPaperSizeList (hdl:LongInt; szPaperSizeList:pChar) : longint; stdcall; external 'powerprn.dll'


dwGetPaperBinList

Description

Get the list of available paper bins. The paper bins are separated by semicolumn (;). Each paper bin consists of a number (Bin ID) and a description. The paper bin can be set by using dwSetDefaultSource . Please refer to the sample applications for an implementation example.

Argument	Description

long	instance handle

string	paper bin list. By reference. Be sure to allocate a buffer large enough.

Return value

long	error code

See also

dwGetNamedPaperBinList

DEVMODE Structure

DEVMODE Constants

Error Codes


dwGetNamedPaperBinList

Description

Get a list of available paper bins. The bin name are separated by semi column (;). This list is more readable (for the end user) than the one returned by dwGetPaperBinList but there is no Bin ID associated. However, the bins are returned in the same order. Please refer to the sample applications for an implementation example.

Argument	Description

long	instance handle

string	paper bin list. By reference. Be sure to allocate a buffer large enough.

Return value

long	error code

See also

dwGetPaperBinList

DEVMODE Structure

DEVMODE Constants

Error Codes


dwGetSupportedPaperSizeList

Description

Return a list of all standard paper size. The list is sepapreted by semi-column (;). Use dwSetPaperSize to change the default paper size. Please refer to the sample applications for an implementation example.

Argument	Description

long	instance handle

string	paper size list.

Return value

long	error code

See also

dwGetPaperSize

dwSetPaperSize

DEVMODE Structure

DEVMODE Constants


Version 1.1 Features

PowerPrinter Version 1.1 has many new APIs. Some of them have been placed into a new module, PowerDIB , that is loaded on demand. This means that if your application does not make use of its APIs then you do not need to include powerdib.dll with your application.

New APIs

‘Windows NT only. These APIs allow you to connect to a network printer from a NT workstation. No need to have the printer driver installed locally. If necessary, NT will get it for you from the (NT) server. Cool, isn’t it ?

dwAddPrinterConnection

dwDeletePrinterConection

‘ Allow you to add/delete a printer to the local port or connect to a network printer. Under NT you can even add a printer to another PC !

dwAddPrinter

dwDeletePrinter

‘ add/delete printer driver on the fly. Driver must be present on the hard disk

dwAddPrinterDriver

dwDeletePrinterDriver

‘Printer Jobs

dwEnumPrinterJobs

‘Printer Fonts

dwEnumPrinterFonts

dwSetPrinterFont

‘Item and List separators

dwGetListSep

dwSetListSep

dwGetItemSep

dwSetItemSep

‘Extended error attributes as set by Windows APIs

dwGetExtendedErrorCode

dwGetExtendedErrorMessage

‘ New paper bin APIs. Now you can the list of paper bins for any printer

dwGetPaperBinListEx

dwGetNamedPaperBinListEx

‘ New API to change the printer port to anything you want (e.g. FILE:)

dwSetDeafultPrinterPort

PowerDIB Apis. Tell me more about PowerDIB

dwCaptureDesktop

dwCaptureWindow

dwPrintTheDIB

Upgrades are free for all registered customers. Otherwise, the normal price of US$35 will apply.


DEVMODE Constants

Values taken from wingdi.h

// orientation selections

#define DMORIENT_PORTRAIT   	1

#define DMORIENT_LANDSCAPE  	2

// paper selections

#define DMPAPER_FIRST	DMPAPER_LETTER

#define DMPAPER_LETTER	1  // Letter 8 1/2 x 11 in

#define DMPAPER_LETTERSMALL	2  // Letter Small 8 1/2 x 11 in

#define DMPAPER_TABLOID	3  // Tabloid 11 x 17 in

#define DMPAPER_LEDGER	4  // Ledger 17 x 11 in

#define DMPAPER_LEGAL	5  // Legal 8 1/2 x 14 in

#define DMPAPER_STATEMENT	6  // Statement 5 1/2 x 8 1/2 in

#define DMPAPER_EXECUTIVE	7  // Executive 7 1/4 x 10 1/2 in

#define DMPAPER_A3	8  // A3 297 x 420 mm

#define DMPAPER_A4	9  // A4 210 x 297 mm

#define DMPAPER_A4SMALL	10  // A4 Small 210 x 297 mm

#define DMPAPER_A5	11  // A5 148 x 210 mm

#define DMPAPER_B4	12  // B4 (JIS) 250 x 354

#define DMPAPER_B5	13  // B5 (JIS) 182 x 257 mm

#define DMPAPER_FOLIO	14  // Folio 8 1/2 x 13 in

#define DMPAPER_QUARTO	15  // Quarto 215 x 275 mm

#define DMPAPER_10X14	16  // 10x14 in

#define DMPAPER_11X17	17  // 11x17 in

#define DMPAPER_NOTE	18  // Note 8 1/2 x 11 in

#define DMPAPER_ENV_9	19  // Envelope #9 3 7/8 x 8 7/8

#define DMPAPER_ENV_10	20  // Envelope #10 4 1/8 x 9 1/2

#define DMPAPER_ENV_11	21  // Envelope #11 4 1/2 x 10 3/8

#define DMPAPER_ENV_12	22  // Envelope #12 4 \276 x 11

#define DMPAPER_ENV_14	23  // Envelope #14 5 x 11 1/2

#define DMPAPER_CSHEET	24  // C size sheet

#define DMPAPER_DSHEET	25  // D size sheet

#define DMPAPER_ESHEET	26  // E size sheet

#define DMPAPER_ENV_DL	27  // Envelope DL 110 x 220mm

#define DMPAPER_ENV_C5	28  // Envelope C5 162 x 229 mm

#define DMPAPER_ENV_C3	29  // Envelope C3  324 x 458 mm

#define DMPAPER_ENV_C4	30  // Envelope C4  229 x 324 mm

#define DMPAPER_ENV_C6	31  // Envelope C6  114 x 162 mm

#define DMPAPER_ENV_C65	32  // Envelope C65 114 x 229 mm

#define DMPAPER_ENV_B4	33  // Envelope B4  250 x 353 mm

#define DMPAPER_ENV_B5	34  // Envelope B5  176 x 250 mm

#define DMPAPER_ENV_B6	35  // Envelope B6  176 x 125 mm

#define DMPAPER_ENV_ITALY	36  // Envelope 110 x 230 mm

#define DMPAPER_ENV_MONARCH	37  // Envelope Monarch 3.875 x 7.5 in

#define DMPAPER_ENV_PERSONAL	38  // 6 3/4 Envelope 3 5/8 x 6 1/2 in

#define DMPAPER_FANFOLD_US	39  // US Std Fanfold 14 7/8 x 11 in

#define DMPAPER_FANFOLD_STD_GERMAN	40  // German Std Fanfold 8 1/2 x 12 in

#define DMPAPER_FANFOLD_LGL_GERMAN	41  // German Legal Fanfold 8 1/2 x 13 in

#if(WINVER >= 0x0400)

#define DMPAPER_ISO_B4	42  // B4 (ISO) 250 x 353 mm

#define DMPAPER_JAPANESE_POSTCARD	43  // Japanese Postcard 100 x 148 mm

#define DMPAPER_9X11	44  // 9 x 11 in

#define DMPAPER_10X11	45  // 10 x 11 in

#define DMPAPER_15X11	46  // 15 x 11 in

#define DMPAPER_ENV_INVITE	47  // Envelope Invite 220 x 220 mm

#define DMPAPER_RESERVED_48	48  // RESERVED--DO NOT USE

#define DMPAPER_RESERVED_49	49  // RESERVED--DO NOT USE

#define DMPAPER_LETTER_EXTRA	50  // Letter Extra 9 \275 x 12 in

#define DMPAPER_LEGAL_EXTRA	51  // Legal Extra 9 \275 x 15 in

#define DMPAPER_TABLOID_EXTRA	52  // Tabloid Extra 11.69 x 18 in

#define DMPAPER_A4_EXTRA	53  // A4 Extra 9.27 x 12.69 in

#define DMPAPER_LETTER_TRANSVERSE	54  // Letter Transverse 8 \275 x 11 in

#define DMPAPER_A4_TRANSVERSE	55  // A4 Transverse 210 x 297 mm

#define DMPAPER_LETTER_EXTRA_TRANSVERSE 56 // Letter Extra Transverse 9\275 x 12 in

#define DMPAPER_A_PLUS	57  // SuperA/SuperA/A4 227 x 356 mm

#define DMPAPER_B_PLUS	58  // SuperB/SuperB/A3 305 x 487 mm

#define DMPAPER_LETTER_PLUS	59  // Letter Plus 8.5 x 12.69 in

#define DMPAPER_A4_PLUS	60  // A4 Plus 210 x 330 mm

#define DMPAPER_A5_TRANSVERSE	61  // A5 Transverse 148 x 210 mm

#define DMPAPER_B5_TRANSVERSE	62  // B5 (JIS) Transverse 182 x 257 mm

#define DMPAPER_A3_EXTRA	63  // A3 Extra 322 x 445 mm

#define DMPAPER_A5_EXTRA	64  // A5 Extra 174 x 235 mm

#define DMPAPER_B5_EXTRA	65  // B5 (ISO) Extra 201 x 276 mm

#define DMPAPER_A2	66  // A2 420 x 594 mm

#define DMPAPER_A3_TRANSVERSE	67  // A3 Transverse 297 x 420 mm

#define DMPAPER_A3_EXTRA_TRANSVERSE 68  // A3 Extra Transverse 322 x 445 mm

#endif // WINVER >= 0x0400

#if (WINVER >= 0x0400)

#define DMPAPER_LAST	DMPAPER_A3_EXTRA_TRANSVERSE

#else

#define DMPAPER_LAST	DMPAPER_FANFOLD_LGL_GERMAN

#endif

#define DMPAPER_USER	256

// bin selections

#define DMBIN_FIRST	DMBIN_UPPER

#define DMBIN_UPPER	1

#define DMBIN_ONLYONE	1

#define DMBIN_LOWER	2

#define DMBIN_MIDDLE	3

#define DMBIN_MANUAL	4

#define DMBIN_ENVELOPE	5

#define DMBIN_ENVMANUAL	6

#define DMBIN_AUTO	7

#define DMBIN_TRACTOR	8

#define DMBIN_SMALLFMT	9

#define DMBIN_LARGEFMT	10

#define DMBIN_LARGECAPACITY	11

#define DMBIN_CASSETTE	14

#define DMBIN_FORMSOURCE	15

#define DMBIN_LAST	DMBIN_FORMSOURCE

#define DMBIN_USER	256     // device specific bins start here

// print qualities

#define DMRES_DRAFT	-1

#define DMRES_LOW 	-2

#define DMRES_MEDIUM	-3

#define DMRES_HIGH	-4

// color enable/disable for color printers

#define DMCOLOR_MONOCHROME	1

#define DMCOLOR_COLOR	2

// duplex enable

#define DMDUP_SIMPLEX	1

#define DMDUP_VERTICAL	2

#define DMDUP_HORIZONTAL	3

// TrueType options

#define DMTT_BITMAP	1       // print TT fonts as graphics

#define DMTT_DOWNLOAD	2       // download TT fonts as soft fonts

#define DMTT_SUBDEV	3       // substitute device fonts for TT fonts

#if(WINVER >= 0x0400)

#define DMTT_DOWNLOAD_OUTLINE	4 // download TT fonts as outline soft fonts

#endif // WINVER >= 0x0400

// Collation selections

#define DMCOLLATE_FALSE	0

#define DMCOLLATE_TRUE	1

// DEVMODE dmDisplayFlags flags

//#define DM_GRAYSCALE 	0x00000001 // This flag is no longer valid

//#define DM_INTERLACED	0x00000002 // This flag is no longer valid

#define DMDISPLAYFLAGS_TEXTMODE	0x00000004

#if(WINVER >= 0x0400)

// ICM methods

#define DMICMMETHOD_NONE	1   // ICM disabled

#define DMICMMETHOD_SYSTEM	2   // ICM handled by system

#define DMICMMETHOD_DRIVER	3   // ICM handled by driver

#define DMICMMETHOD_DEVICE	4   // ICM handled by device

#define DMICMMETHOD_USER	256   // Device-specific methods start here

// ICM Intents

#define DMICM_SATURATE	1   // Maximize color saturation

#define DMICM_CONTRAST	2   // Maximize color contrast

#define DMICM_COLORMETRIC	3   // Use specific color metric

#define DMICM_USER	256   // Device-specific intents start here

// Media types

#define DMMEDIA_STANDARD	1   // Standard paper

#define DMMEDIA_TRANSPARENCY	2   // Transparency

#define DMMEDIA_GLOSSY	3   // Glossy paper

#define DMMEDIA_USER	256   // Device-specific media start here

// Dither types

#define DMDITHER_NONE	1   // No dithering

#define DMDITHER_COARSE	2   // Dither with a coarse brush

#define DMDITHER_FINE	3   // Dither with a fine brush

#define DMDITHER_LINEART	4   // LineArt dithering

#define DMDITHER_GRAYSCALE	5   // Device does grayscaling

#define DMDITHER_USER	256   // Device-specific dithers start here


dwGetPrinterAccess

Description

Return the printer access used by PowerPrinter. The default is PRINTER_ACCESS_USE. Use dwSetPrinterAccess to change it.

Argument	Description

long	instance handle

Return value

long	printer access

See also

dwSetPrinterAccess


dwSetPrinterAccess

Description

This function allows you to set the printer access type to be used by PowerPrinter. The default is PRINTER_ALL_ACCESS.

// From winspool.h

#define PRINTER_ACCESS_ADMINISTER	0x00000004

#define PRINTER_ACCESS_USE	0x00000008

#define PRINTER_ALL_ACCESS    	(STANDARD_RIGHTS_REQUIRED | PRINTER_ACCESS_ADMINISTER | PRINTER_ACCESS_USE)

#define PRINTER_READ   	(STANDARD_RIGHTS_READ | PRINTER_ACCESS_USE)

#define PRINTER_WRITE         	(STANDARD_RIGHTS_WRITE | PRINTER_ACCESS_USE)

#define PRINTER_EXECUTE       	(STANDARD_RIGHTS_EXECUTE | PRINTER_ACCESS_USE)

Argument	Description

long	instance handle

long	Printer access.

Return value

long	error code. The printer access is currently not checked. The function returns always 1.

See also

dwGetPrinterAccess


dwAddPrinterConnection

Description

This API allows you to adds a connection to the specified printer for the current user. This API is available for NT only. There is no need to install the printer driver locally: the driver is automatically downloaded from the server. However, the user needs the permission to copy files to the appropriate location.

NB: This API should not be used to connect to a local printer !. Use dwAddPrinter  instead.

Argument	Description

long	instance handle

string	Server name

string	printer share name

Return value

int	non-zero if the function succeed. Zero if the function fails.

See also

dwDeletePrinterConection

dwSetPrinterAccess


dwDeletePrinterConection

Description

The dwDeletePrinterConnection function deletes a connection to a printer that was established by a call to dwAddPrinterConnection. This feature is available only on NT platforms. The dwDeletePrinterConnection function does not delete any printer drivers copied to the server on which the printer resides when the printer connection was established.

Argument	Description

long	instance handle

string	server name

string	printer name

Return value

int	non-zero if the function succeed. Zero if the function fails.

See also

dwAddPrinterConnection


dwAddPrinter

Description

Windows NT:The caller of the AddPrinter function must have SERVER_ACCESS_ADMINISTER access to the server on which the printer is to be created. The handle returned by the function will have PRINTER_ALL_ACCESS permission, and can be used to perform administrative operations on the printer. The default printer access of PowerPrinter is PRINTER_ALL_ACCESS. It can be changed with dwSetPrinterAccess .

Argument	Description

long	instance handle

String	Server name. NT only

String	printer name

string	port name

string	driver name

string	print processor used by the printer

Return value

long	non-zero if the function succeed. Zero if the function fails.

See also

dwDeletePrinter

dwAddPrinterConnection

dwDeletePrinterConection


dwDeletePrinter

Description

Delete a printer on any PC or Server. When deleting printer names on another PC you have to prefix the printer name with the remote PC name. For example, \\SERVER\PRN_SHARE_NAME

Argument	Description

long	instance handle

string	printer share name

Return value

long	non-zero if the function succeed. Zero if the function fails.

See also

dwAddPrinter

dwAddPrinterConnection

dwDeletePrinterConection


dwAddPrinterDriver

Description

This API allows you to add a printer driver. You normally need the driver before being able to install a printer with dwAddPrinter . Before an application calls the dwAddPrinterDriver function, all files required by the driver must be copied to the system's printer-driver directory. See How to add a printer for an example and a description of function parameters.

However, when using NT servers, you can use dwAddPrinterConnection which downloads printer drivers from the server automatically.

Argument	Description

long	instance handle

string	Pointer to a null-terminated string that specifies the name of the server where the driver should be installed. If the argument is NULL, the driver will be installed locally.

String	Null terminated string that specifies the printer name.

String	Environment. Normally Windows NT x86 or Windows 4.0

string	driver path

string	data file

string 	config file

long	version

Return value

long	1 if successful or a negative value otherwise.

See also

How to add a printer

dwDeletePrinterDriver

dwAddPrinterConnection

dwDeletePrinterConection

Error Codes


dwDeletePrinterDriver

Description

The dwDeletePrinterDriver function removes the specified printer-driver name from the list of names of supported drivers for a server. It does not remove the driver filesfrom the server.

Argument	Description

long	instance handle

string	printer name

string	environment. Normally Windows NT x86 or Windows 4.0

string	driver name

Return value

long	1 if successful or a negative value otherwise.

See also

How to add a printer

dwAddPrinterDriver


dwGetExtendedErrorCode

Description

This API allows you retrieve the extended error code set by Windows APIs. These are not PowerPrinter erro codes but can be used to get additional information when an API call fails.

Argument	Description

long	instance handle

Return value

long	The error code as defined in the SDK. Zero means success.

See also

dwGetExtendedErrorMessage


dwGetExtendedErrorMessage

Description

The function returns a string with the error details. Please note that these are not PowerPrinter errors but Windows API ones. Most Windows APIs set an error code when they fail and this API allows you to see exactly why.

When the error code is zero then the error message is ‘The operation completed successfully’.

Argument	Description

long	instance handle

string	return the extended error message by reference.

Return value

none	n/a

See also

dwGetExtendedErrorCode


How to add a printer

We have included sample screen shot of the sample application to show typical usage of the dwAddPrinter , dwDeletePrinter  PowerPrinter APIs.

Using these APIs you are able to add a printer (local or network) either locally or, if running under NT, to a remote PC.

Example 1: Use the parameters shown below to add a printer named PRNTEST to a server named SERVER. Remove the server name to add it locally. Again, under NT only.

Example 2: To delete a printer you have to prefix the printer name by the server name when deleting a remote printer.

Example 3: Add a local printer.

Example 4: Add a network printer. The only difference is the PORT name which is the server name (where the printer is) and the printer share name.


dwGetListSep

Description

This API returns the character separator that PowerPrinter uses to separate items within a list. The string parameter can contain up to two characters and must be passed by reference.

Argument	Description

long	instance handle

string	item separator string. By reference. Allocate a string of at least 3 characters

Return value

long	1 if no error occurred. Negative value otherwise.

See also

dwSetListSep

dwGetItemSep

dwSetItemSep

Error Codes


dwSetListSep

Description

Set separator character (up to two characters) that PowerPrinter uses to separate items within a list.

Argument	Description

long	instance handle

string	List separator

Return value

long	1 if no error occurred. Negative value otherwise.

See also

dwGetListSep

dwGetItemSep

dwSetItemSep

Error Codes


dwGetItemSep

Description

Get the character string use to separate items within a list.

Argument	Description

long	instance handle

string	The item separator character. By reference. Allocate a buffer of at least 3 characters

Return value

long	1 if no error occurred. Negative value otherwise.

See also

dwGetItemSep

dwGetListSep

dwSetListSep

Error Codes


dwSetItemSep

Description

Set the character to be used to separate items. Sometimes PowerPrinter returns structures as strings were items are separated by #. Use this API if you want to use another character. Actually, PowerPrinter can use strings up to two characters to hold, for example, CR + LF.

Argument	Description

long	instance handle

string	Item separator. Max 2 chars

Return value

long	1 if no error occurred. Negative value otherwise.

See also

dwGetItemSep

dwSetListSep

dwGetListSep

Error Codes


dwEnumPrinterFonts

Description

Enumerate all printer fonts. Since Windows maps screen fonts to the closest printer font it can be useful to verify which font the printer supports. The font list is copied to the string parameter. Such parameter must be initialised to a string large enough.

Argument	Description

long	instance handle

string	printer font list. By reference. Allocate memory for the string before calling the API

Return value

long	The number of printer fonts if successful or -1 if failed.

See also

dwSetPrinterFont

Error Codes


dwSetPrinterFont

Description

This API allows you to change the default printer font for the specified printer.

Argument	Description

long	instance handle

HDC	pointer to printer DC

String	font face name

short	point size

short	bold. 0 = normal, 1 = bold

Short 	italic. 0 = normal, 1 = italic

Short	underline. 0 = normal, 1 = underlined

short	strike through. 0 = normal, 1 = strike through effect

Return value

long	1 if no error occurred. Negative value otherwise.

See also

dwEnumPrinterFonts

Error Codes


dwCaptureDesktop

Description

Capture Windows desktop into a Device Independent Bitmap (DIB). The DIB can then be printed using dwPrintTheDIB .

Argument	Description

long	instance handle

Return value

long	1 if no error occurred. Negative value otherwise.

See also

PowerDIB

dwCaptureDesktop

Error Codes


dwPrintTheDIB

Description

Print the Device Independent Bitmap captured with dwCaptureDesktop . It is important that powerdib.dll is either in the same directory as powerprn.dll or in the path. Powerprn.dll is linked dynamically when you call its APIs.

Argument	Description

long	instance handle

long	Print option. Use 120 to have the DIB to stretch to full page or 119 to print normally.

String	Print caption. The caption identifies a print job (shown in the spooler queue)

Return value

long	1 if no error occurred. Negative value otherwise.

See also

PowerDIB

dwCaptureDesktop

Error Codes


PowerDIB

PowerDIB is a new DLL that contains a few handy APIs to manipulate Device Independent Bitmaps (DIB). Currently, PowerDIB contains only an API to capture the desktop image and an API to print it.

PowerDIB will probably evolve into a standalone product. However, current PowerPrinter customers will not be charged for it. They will automatically receive their user name and KEY for free. This means that if you are using PowerDIB APIs now we will not charge you any money. As always, feedback and ideas are welcome.

IMPORTANT: PowerDIB APIs are linked dynamically from PowerPrinter. This means that you do not need powerdib.dll if you do not make use of its APIs. In other words, you need to distribute only powerprn.dll if you don’t use the APIs listed below.

Current PowerDIB APIs

dwCaptureDesktop

dwCaptureWindow

dwPrintTheDIB


dwEnumPrinterJobs

Description

Enumerate all print jobs currently in the printer spooler queue. The following API does not work under VisualBasic because VB uses OLE strings which are not compatibles. Please refer to VB Strings for details.

Argument	Description

long	instance handle

string	printer name

long	maximum number of jobs to return

JOB_INFO_1	data structure array with print jobs info. By reference.

Long	number of print jobs actually returned. By reference.

Return value

long	1 if successful or a negative value otherwise

See also

JOB_INFO_1

Error Codes

dwGetExtendedErrorCode

dwGetExtendedErrorMessage


dwGetPrinterDrivers

Description

The dwGetPrinterDrivers function enumerates all of the printer drivers installed locally. This API makes use of a standard Windows data structure DRIVER_INFO_2 . Actually, this API expect an array of such structure to be passed in by reference. The array has to be initialised before calling the API. The samples applications show you how this can be done. The following API does not work under VisualBasic because VB uses OLE strings which are not compatibles. Please refer to VB Strings for details.

Argument	Description

long	instance handle

DRIVER_INFO_2	Data structure array that contains all driver info.

Long	Maximum number of printer drivers to retrieve. The array has to initalised before calling to function.

Short	Number of drivers actually found. Passed by reference.

Return value

long	1 if successful or a negative number otherwise.

See also

DRIVER_INFO_2

Error Codes

dwGetExtendedErrorCode

dwGetExtendedErrorMessage


DRIVER_INFO_2

The DRIVER_INFO_2 structure identifies a printer driver, the driver version number, the environment for which the driver was written, the name of the file in which the driver is stored, and so on.

typedef struct _DRIVER_INFO_2 {

    DWORD  cVersion;

    LPTSTR pName;

    LPTSTR pEnvironment;

    LPTSTR pDriverPath;

    LPTSTR pDataFile;

    LPTSTR pConfigFile;

} DRIVER_INFO_2;

Members

cVersion

Specifies a printer-driver version number.

pName

Points to a null-terminated string that specifies the name of the driver (for example, "QMS 810").

pEnvironment

Points to a null-terminated string that specifies the environment for which the driver was written (for example, "Windows NT x86" or "Windows NT R4000").

pDriverPath

Points to null-terminated string that specifies a filename or full path and filename for the file that contains the device driver (for example, "c:\drivers\pscript.dll").

pDataFile

Points to a null-terminated string that specifies a filename or a full path and filename for the file that contains driver data (for example, "c:\drivers\QMS810.PPD").

pConfigFile

Points to a null-terminated string that specifies a filename or a full path and filename for the device-driver's configuration DLL (for example, "c:\drivers\PSCRPTUI.DLL").


dwGetPrinterDriver

Description

The dwGetPrinterDriver function retrieves driver data for the specified printer.

Argument	Description

long	instance handle

string	Identifies the printer for which the driver data should be retrieved.

DRIVER_INFO_2	Data structure with driver info. This parameter passed by reference.

Return value

long	1 if successful or a negative value otherwise.

See also

DRIVER_INFO_2

Error Codes

dwGetExtendedErrorCode

dwGetExtendedErrorMessage


JOB_INFO_1

The JOB_INFO_1 Structure is only by the dwEnumPrinterJobs API. It is a standard Windows structure and it is documented in the Windows SDK. Its main purpose it is return information about print jobs.

Type JOB_INFO_1

        JobId As Long

        pPrinterName As String

        pMachineName As String

        pUserName As String

        pDocument As String

        pDatatype As String

        pStatus As String

        Status As Long

        Priority As Long

        Position As Long

        TotalPages As Long

        PagesPrinted As Long

        Submitted As SYSTEMTYME

End Type

See also

SYSTEMTYME


SYSTEMTYME

The SYSTEMTIME structure is a standard Windows structure used by many Windows APIs. The following definition has been taken from the latest Windows SDK.

Type SYSTEMTIME

        wYear As Integer

        wMonth As Integer

        wDayOfWeek As Integer

        wDay As Integer

        wHour As Integer

        wMinute As Integer

        wSecond As Integer

        wMilliseconds As Integer

End Type


dwCaptureWindow

Description

This API allows you to copy the image of a Window to a DIB given the window handle. Moreover, you can choose to copy either the complete window or only the client area.

Argument	Description

long	instance handle

HWND	Window Handle

ushort	Copy option. Use 1 to copy the entire Window or 2 to copy only the client area.

Return value

long	1 if successful or a negative value otherwise.

See also

PowerDIB

dwCaptureDesktop

dwPrintTheDIB

Error Codes


dwGetPaperBinListEx

Description

Get the list of available paper bins for a given printer. The paper bins are separated by semicolumn (;). Each paper bin consists of a number (Bin ID) and a description. The paper bin of the default printer can be set by using dwSetDefaultSource .

Argument	Description

long	instance handle

string	Printer name

string	paper bin list. By reference. Be sure to allocate a buffer large enough.

Return value

long	error code

See also

dwGetNamedPaperBinListdwGetNamedPaperBinList

DEVMODE Structure

DEVMODE Constants

Error Codes


dwGetNamedPaperBinListEx

Description

Get a list of available paper bins for a given printer. The bin name are separated by semi column (;). This list is more readable (for the end user) than the one returned by dwGetPaperBinListEx but there is no Bin ID associated. However, the bins are returned in the same order.

Argument	Description

long	instance handle

string	printer name

string	paper bin list. By reference. Be sure to allocate a buffer large enough.

Return value

long	error code

See also

dwGetPaperBinListEx

DEVMODE Structure

DEVMODE Constants

Error Codes


dwSetDeafultPrinterPort

Description

This API allows you to change the printer port for the default printer. This API is particularly useful if you want to print to a file. Beware that when printing to FILE: the Windows sub-system prompts you for a file name. There is a workaround for NT users that consists in using dwSetDefaultPrinterEx and setting FILE:c:\ filename.prn as port. Of course, you can use the path and filename you want.

Argument	Description

long	instance handle

string	printer port

Return value

long	error code. Greater than zero if successful

See also

dwGetDefaultPrinterEx

dwSetDefaultPrinterEx

Error Codes


VB Strings

VisualBasic version 4 begun using OLE strings both internally and for external function calls. Such strings are different because they contain an additional header that specifies the length of the string – known as safe strings. This is not a real problem when passing simple strings as arguments to DLLs because by passing them ByVal VB does the conversion for us. The problem exists when using arrays of structures.

We are evaluating the possibility of developing a VB version of the APIs shown below, which do not work under VB, but we will do so only if there is a real need for it. If you really need to use such APIs please send us a note at powerprinter@digitalw.com .

Incompatible APIs

dwEnumPrinterJobs

dwGetPrinterDrivers


16 Bit Version

A large number of people expressed the need for a 16 Bit version of PowerPrinter. We have decided to implement a scaled down version of PowerPrinter to support basic printer functionalities such as the ability to choose a printer form a list, set the default printer, and change printer orientation.

The 16 Bit version shares the same API as the 32 bit version and no modification is necessary when porting your apps from 16 Bit windows to Windows NT & 95.

Please check our web site at http://www.digitalw.comfor availability.