|
|
PROG |
| 22 Haz 2001 | GET DEFAULT PRINTER NAME | VC++ Articels |
|
It is sometimes
necessary to fetch the name of the default printer (queue) name for Windows from within a
program. The Win32 API provides the function GetDefaultPrinter for this, but unfortunately
this function only works in Win/2000 or later. The routine
GET_DEF_PRINTER routine lets you get the default printer name for any version of Windows
after (and including) Windows/95. The routine is
available as part of the C++ source file EXAM41.CPP. The routine has the following calling
parameters: int
GET_DEF_PRINTER(char *,int *) where a character
buffer is supplied to receive the default printer name, as well as a pointer to an integer
that contains the max size of the character buffer. The second parameter (the max buffer
size) is modified by the routine to contain the actual length of the printer name (in
bytes). The default printer name is returned as a zero-terminated string. The return value is
zero if the printer name was retrieved successfully. See the comments in the source code
for other possible return codes. Note that this
routine modifies the values for both the character string and the integer length. You can download
the file in ZIP format by clicking on the following link. Download
Exam41.zip (3 kB, last modified: 1/15/2001) This works for
Microsoft Windows 95/98/ME/NT/2000. I have tested with Visual C++ v6.0 but it should work
with other versions also. Please let me know of exceptions. After downloading,
unzip the file Exam41.cpp into any folder. It contains a short Windows console program
which demonstrates how to call GET_DEF_PRINTER to find the default printer name. If you have any
questions please send them to the e-mail address below. |
|
|
|
home | about me | links | projects | clean energy | programming | |