J
Jason
Hi, I am new to windows api programming and I wanted to create a little
utility program for myself in c using the mini gw compiler. I bought
petzold's book, programming windows 5th edition. I know the book was
written for people using visual c++ 6, win98/NT before xp came along but
thought it would be ok. My problem is that having lifted an example of code
in the GetPrinterDC function(pasted below) the compiler seems to take
exception to the enumprinters function and gives the following message for
each instance of it.
printer.o(.text+0x6c)rinter.c: undefined reference to `EnumPrintersA@28'
actually, it compiles ok, but the above message is at the linking stage i
think, having issued this command 'gcc -mwindows -o printer.exe printer.o'.
I included windows.h. can anybody help me on this?
the enumprinters function is described as filling an array of structures
with information on attached printers, allowing the function GetPrinterDC to
return a handle for the printer device context.
Is there a major flaw in my plan to use this book for creating GUI on this
compiler and xp assuming you know the book anyway? I want to learn windows
api stuff, though i find it frustrating that this function doesnt appear to
be known. Does it take a different set of arguments in xp?
Apart from this problem can anyone point me to further resources for doing
windows development on the minigw compiler. If there is a free GUI library
around that allows me to create and destroy windows, print etc and hides all
these details I would be interested to explore that possibility too.
thanks in advance!
HDC GetPrinterDC (void)
{
DWORD dwNeeded, dwReturned ;
HDC hdc ;
PRINTER_INFO_4 * pinfo4 ;
PRINTER_INFO_5 * pinfo5 ;
if (GetVersion () & 0x80000000) // Windows 98
{
EnumPrinters (PRINTER_ENUM_DEFAULT, NULL, 5, NULL,
0, &dwNeeded, &dwReturned) ;
pinfo5 = malloc (dwNeeded) ;
EnumPrinters (PRINTER_ENUM_DEFAULT, NULL, 5, (PBYTE) pinfo5,
dwNeeded, &dwNeeded, &dwReturned) ;
hdc = CreateDC (NULL, pinfo5->pPrinterName, NULL, NULL) ;
free (pinfo5) ;
}
else // Windows NT
{
EnumPrinters (PRINTER_ENUM_LOCAL, NULL, 4, NULL,
0, &dwNeeded, &dwReturned) ;
pinfo4 = malloc (dwNeeded) ;
EnumPrinters (PRINTER_ENUM_LOCAL, NULL, 4, (PBYTE) pinfo4,
dwNeeded, &dwNeeded, &dwReturned) ;
hdc = CreateDC (NULL, pinfo4->pPrinterName, NULL, NULL) ;
free (pinfo4) ;
}
return hdc ;
}
utility program for myself in c using the mini gw compiler. I bought
petzold's book, programming windows 5th edition. I know the book was
written for people using visual c++ 6, win98/NT before xp came along but
thought it would be ok. My problem is that having lifted an example of code
in the GetPrinterDC function(pasted below) the compiler seems to take
exception to the enumprinters function and gives the following message for
each instance of it.
printer.o(.text+0x6c)rinter.c: undefined reference to `EnumPrintersA@28'
actually, it compiles ok, but the above message is at the linking stage i
think, having issued this command 'gcc -mwindows -o printer.exe printer.o'.
I included windows.h. can anybody help me on this?
the enumprinters function is described as filling an array of structures
with information on attached printers, allowing the function GetPrinterDC to
return a handle for the printer device context.
Is there a major flaw in my plan to use this book for creating GUI on this
compiler and xp assuming you know the book anyway? I want to learn windows
api stuff, though i find it frustrating that this function doesnt appear to
be known. Does it take a different set of arguments in xp?
Apart from this problem can anyone point me to further resources for doing
windows development on the minigw compiler. If there is a free GUI library
around that allows me to create and destroy windows, print etc and hides all
these details I would be interested to explore that possibility too.
thanks in advance!
HDC GetPrinterDC (void)
{
DWORD dwNeeded, dwReturned ;
HDC hdc ;
PRINTER_INFO_4 * pinfo4 ;
PRINTER_INFO_5 * pinfo5 ;
if (GetVersion () & 0x80000000) // Windows 98
{
EnumPrinters (PRINTER_ENUM_DEFAULT, NULL, 5, NULL,
0, &dwNeeded, &dwReturned) ;
pinfo5 = malloc (dwNeeded) ;
EnumPrinters (PRINTER_ENUM_DEFAULT, NULL, 5, (PBYTE) pinfo5,
dwNeeded, &dwNeeded, &dwReturned) ;
hdc = CreateDC (NULL, pinfo5->pPrinterName, NULL, NULL) ;
free (pinfo5) ;
}
else // Windows NT
{
EnumPrinters (PRINTER_ENUM_LOCAL, NULL, 4, NULL,
0, &dwNeeded, &dwReturned) ;
pinfo4 = malloc (dwNeeded) ;
EnumPrinters (PRINTER_ENUM_LOCAL, NULL, 4, (PBYTE) pinfo4,
dwNeeded, &dwNeeded, &dwReturned) ;
hdc = CreateDC (NULL, pinfo4->pPrinterName, NULL, NULL) ;
free (pinfo4) ;
}
return hdc ;
}