Originally Posted by
knutso
I've tried all different flag versions.
The function call returns successfully, but does not return printers connected through the network...
Hmm...
Try this...I havent checked it on Win2000 but see if it works
Code:
#include <windows.h>
#include <iostream>
int main()
{
DWORD Needed = 0,Found = 0;
union PRINT_INFO_ENUM
{
PRINT_INFO_ENUM():AsBytes(0){}
LPBYTE AsBytes;
PRINTER_INFO_1 *AsInfo;
}PrinterInfo;
//Get size of array
EnumPrinters( PRINTER_ENUM_LOCAL | PRINTER_ENUM_CONNECTIONS ,0,1,0,1,&Needed,&Found);
try
{
PrinterInfo.AsBytes = new BYTE[Needed];
}
catch(...)
{
std::cout << "Memory Error";
return -1;
}
//Enum
if(!EnumPrinters(PRINTER_ENUM_LOCAL | PRINTER_ENUM_CONNECTIONS ,0,1,
PrinterInfo.AsBytes,Needed,&Needed,&Found))
{
std::cout << "Unable to enumerate " << GetLastError();
return -1;
}
for(DWORD i = 0;i < Found;++i)
std::cout << PrinterInfo.AsInfo[i].pName << std::endl;
delete [] PrinterInfo.AsBytes;
}