I'm trying to get the name of the default printer with GetDefaultPrinter. I'm using WinXP.
The Problem is I'm always getting an "undefined reference" error from the linker, although I have included the libwinspool for linking(I'm succesfully using other functions from libwinspool).
Any idea?
Thanks.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Could you post your "Basic 3" please - see the thread titled "Please Read Before Posting a Question" in this forum for what they are if you do not know.
Wayne
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Whenever you come across a problem like this the first thing to do is look in the related headers to see if the function is actually declared, and if it is, is it inside an #if block.
b_a
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
BOOL
WINAPI
GetDefaultPrinterA(
IN LPSTR pszBuffer,
IN LPDWORD pcchBuffer
);
BOOL
WINAPI
GetDefaultPrinterW(
IN LPWSTR pszBuffer,
IN LPDWORD pcchBuffer
);
ifdef UNICODE
define GetDefaultPrinter GetDefaultPrinterW
else
define GetDefaultPrinter GetDefaultPrinterA
endif // !UNICODE
b_a
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
I'm trying to get the name of the default printer with GetDefaultPrinter. I'm using WinXP.
The Problem is I'm always getting an "undefined reference" error from the linker, although I have included the libwinspool for linking(I'm succesfully using other functions from libwinspool).
Any idea?
Thanks.
Could you post your "Basic 3" please - see the thread titled "Please Read Before Posting a Question" in this forum for what they are if you do not know.
Wayne
Ok, now that I'm on my home computer where I actually have a reasonably up to date version of dev, I see that they have this in winspool.h
if _WIN32_WINNT >= 0x0500
BOOL WINAPI GetDefaultPrinterA(LPSTR,LPDWORD);
BOOL WINAPI GetDefaultPrinterW(LPWSTR,LPDWORD);
endif
So, you have to add a line like this to your code
define _WIN32_WINNT 0x0500
Whenever you come across a problem like this the first thing to do is look in the related headers to see if the function is actually declared, and if it is, is it inside an #if block.
b_a
Have you looked in the winspool.h file to see if GetDefaultPrinter is declared? Sometimes things are left out of the header files.
If it isn't you can add this to your code (or in winspool.h) and see if it works.
I got this from
http://www.cs.bgu.ac.il/~pcprogs/install/Microsoft_SDK/Include/WinSpool.h
BOOL
WINAPI
GetDefaultPrinterA(
IN LPSTR pszBuffer,
IN LPDWORD pcchBuffer
);
BOOL
WINAPI
GetDefaultPrinterW(
IN LPWSTR pszBuffer,
IN LPDWORD pcchBuffer
);
ifdef UNICODE
define GetDefaultPrinter GetDefaultPrinterW
else
define GetDefaultPrinter GetDefaultPrinterA
endif // !UNICODE
b_a
Oh, just looked at that again.. I think you'll probably need to remove the word IN in those declarations..
b_a