DWORD dwNeeded = 0;
DWORD dwReturned = 0;
EnumPrinters(PRINTER_ENUM_LOCAL, NULL, 5, NULL, 0, &dwNeeded,
&dwReturned);
if (dwNeeded) {
LPPRINTER_INFO_5 ppi = (LPPRINTER_INFO_5)malloc(dwNeeded);
EnumPrinters(PRINTER_ENUM_LOCAL, NULL, 5, (LPBYTE)ppi, dwNeeded,
&dwNeeded, &dwReturned);
free(dwNeeded);
}
dwReturn = 1
I've also tried different PRINTER_ENUM_XXX flags but still same. Enum
network even return no printer at all.
Do you have any idea?
Thanks,
Hiu Sing Ngai
That whole printer stuff is a bit tricky... no, It's helluva
tricky. PRINTER_ENUM_CONNECTIONS is your friend, but I'm not
sure that it works with level 5. Here's a snippet of my code
which works correctly (I think so):
VERSIONINFO VI;
LPBYTE pPIBuffer;
PRINTER_INFO_4* lpPI4;
PRINTER_INFO_5* lpPI5;
...
GetVersionEx(&VI);
if (VI%dwPlatformId == VER_PLATFORM_WIN32_NT)
{
iFlags = PRINTER_ENUM_CONNECTIONS | PRINTER_ENUM_LOCAL;
iLevel = 4;
iSize = sizeof(PRINTER_INFO_4);
}
else
{
iFlags = PRINTER_ENUM_LOCAL;
iLevel = 5;
iSize = sizeof(PRINTER_INFO_5);
}
nB = 0;
nPrinters = 0;
EnumPrinters(iFlags, NULL, iLevel, NULL, 0, &nB, &nPrinters);
pPIBuffer = new char[nB];
lpPI4 = (PRINTER_INFO_4*)pPIBuffer;
lpPI5 = (PRINTER_INFO_5*)pPIBuffer;
if (EnumPrinters(iFlags, NULL_CHAR, iLevel, pPIBuffer, nB, &nB, &nPrinters)
...
HTH
Jugoslav
___________
www.geocities.com/jdujic
Hiu Sing Ngai
"Jugoslav Dujic" <jdujic...@uns.ns.ac.yu> wrote in message
news:a8uted$vc87k$1...@ID-106075.news.dfncis.de...