I think you need to call EnumPrinters twice, the first time to find out how much memory is required to store the information returned, and the second time to actually get that information. It probably doesn't work unless you allocate enough memory for the information returned. Also, to enumerate all printers, use PRINTER_ENUM_LOCAL refer MSDN for details http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/prntspol_9fjn.asp[^] sample code
DWORD dwSizeNeeded = 0;
DWORD dwPrinterCount = 0;
BOOL bEnumResult;
CString strErr;
HANDLE hProcessHeap = GetProcessHeap();
LPPRINTER_INFO_2 lpPrinterData;
// call once to find buffer size
EnumPrinters(PRINTER_ENUM_LOCAL, NULL, 2, NULL, 0, &dwSizeNeeded, &dwPrinterCount);
// allocate buffer memory
if ((lpPrinterData = (LPPRINTER_INFO_2)HeapAlloc(hProcessHeap,
HEAP_ZERO_MEMORY, dwSizeNeeded)) == NULL)
{
// error
return;
}
// call again with new buffer size
bEnumResult = EnumPrinters (PRINTER_ENUM_LOCAL,
NULL,
2,
(LPBYTE)lpPrinterData,
dwSizeNeeded,
&dwSizeNeeded,
&dwPrinterCount);
if (bEnumResult) {
if (dwPrinterCount == 0) {
// no printers installed
HeapFree(hProcessHeap, 0, lpPrinterData);
return;
}
// got data, process it here
}
// clean up and return
HeapFree(hProcessHeap, 0, lpPrinterData);
return;