I have been glancing at this link http://msdn.microsoft.com/en-us/libr...13(VS.85).aspx to learn more about how to use the function, but I'm confused about the differences between each DRIVER_INFO structure beside which operating system each can be used under. It just lists its members under the description of each DRIVER_INFO structure. Any type of explanations would be much appreciated. Thanks.
Google'n found example usage here: http://www.google.com/codesearch?hl=.../ThirdPage.cpp
Level - which structure you want
pcReturned - number of structures returned.
So you call it the first time to see how much memory you need. Then call again to get an array of the requested structures. pcReturned tells you have many structures there are in the array.
Thanks for your reply. I guess my initial confusion was which structure to pick in the first place. Do you have any recommendations besides picking the newest one possible?
Depends on what information you're looking for, and what win-flavors you intend to run on. It's up to you.
I have another question about the structure. Right now I have some code that looks like this, which uses a similar structure as the example that you've pulled up:
My question is that for my test cout statements, I'm always getting outputs that show a sequence of 8 hexadecimal numbers. Could that be b/c of the unicode business? Also, would there be any specific guidelines on finding a printer driver with a particular cell information?
PDFPRNINSTAPI BOOL PDFPRNINSTCALL PdfPrnInstDriverExistsW(WCHAR* pServerName,
// variable declarations
//PDRIVER_INFO_6W pinfo = NULL;
LPBYTE pinfo = NULL;
DWORD pcbNeeded; // just to hold info on amount of bytes copied to
// driverInfo buffer
DWORD numDriversExist; // Number of drivers exist
// enumerates installed drivers
6, /* level uses the latest one */
if(pcbNeeded > 0)
pinfo = (LPBYTE) malloc(pcbNeeded);
catch (char* e)
pinfo = NULL;
printf("Exception raised: %s\n", e);
// now find the printer with the driver name
ok = EnumPrinterDriversW(NULL,
DRIVER_INFO_6W *foundInfo = (DRIVER_INFO_6W*) pinfo;
for (DWORD i=0; i < numDriversExist; i++)
// Print out information on the printers
cout << "Iteration " << i << endl;
cout << "pName = " << foundInfo[i].pName << endl;
cout << "pDriverPath = " << foundInfo[i].pDriverPath << endl;
// Print out numDriversExist references
printf("pcbNeeded = %d\n", pcbNeeded);
printf("numDriversExist = %d\n", numDriversExist);
// return true if the printer driver exists, else false
>> Could that be b/c of the unicode business?
Yeah. You can use wcout for wide strings.
>> any specific guidelines on finding a printer driver with a particular cell information?
wcout << L"pName = " << foundInfo[i].pName << endl;
wcout << L"pDriverPath = " << foundInfo[i].pDriverPath << endl;
Not sure what you mean by "cell information" - but these API's are all new to me anyways :)
Other code improvements:
- mixing C and C++ a bit - using malloc instead of new, printf(), etc..
- error checking