if (::EnumPrinters ( aWhichPrinters, NULL, 2, NULL, 0, &dwSizeNeeded, &dwNumItems )) { return NS_ERROR_FAILURE;
PR_PL(("-----------------------\n")); PR_PL(("EnumerateNativePrinters\n"));  TCHAR szDefaultPrinterName[1024]; DWORD status = GetProfileString("devices", 0, ",", szDefaultPrinterName, sizeof(szDefaultPrinterName)/sizeof(TCHAR)); if (status > 0) { DWORD count = 0; LPTSTR sPtr   = (LPTSTR)szDefaultPrinterName; LPTSTR ePtr   = (LPTSTR)(szDefaultPrinterName+(status*sizeof(TCHAR))); LPTSTR prvPtr = sPtr; while (sPtr < ePtr) { if (*sPtr == NULL) { LPTSTR name = _tcsdup(prvPtr); mPrinters->AppendElement(name); PR_PL(("Printer Name:    %s\n", prvPtr)); prvPtr = sPtr+1; count++; } sPtr++; } rv = NS_OK;
EnumerateNativePrinters(DWORD aWhichPrinters, LPTSTR aPrinterName, PRBool& aIsFound, PRBool& aIsFile){  DWORD             dwSizeNeeded = 0;  DWORD             dwNumItems   = 0;  LPPRINTER_INFO_2  lpInfo        = NULL;  // Get buffer size  if (::EnumPrinters ( aWhichPrinters, NULL, 2, NULL, 0, &dwSizeNeeded, &dwNumItems )) {    return NS_ERROR_FAILURE;  }  // allocate memory  lpInfo = (LPPRINTER_INFO_2)HeapAlloc ( GetProcessHeap (), HEAP_ZERO_MEMORY, dwSizeNeeded );  if ( lpInfo == NULL ) {    return NS_ERROR_OUT_OF_MEMORY;  }  if (::EnumPrinters ( PRINTER_ENUM_LOCAL, NULL, 2, (LPBYTE)lpInfo, dwSizeNeeded, &dwSizeNeeded, &dwNumItems) == 0 ) {    ::HeapFree(GetProcessHeap (), 0, lpInfo);    return NS_OK;  }  for (DWORD i = 0; i < dwNumItems; i++ ) {    if (_tcscmp(lpInfo[i].pPrinterName, aPrinterName) == 0) {      aIsFound = PR_TRUE;      aIsFile  = _tcscmp(lpInfo[i].pPortName, _T("FILE:")) == 0;      break;    }  }  ::HeapFree(GetProcessHeap (), 0, lpInfo);  return NS_OK;}