CSDN博客

img bohut

枚举打印机名

发表于2004/10/26 10:03:00  939人阅读

DWORD            dwFlags = PRINTER_ENUM_FAVORITE | PRINTER_ENUM_LOCAL;
LPPRINTER_INFO_2 pPrinters;
DWORD            cbPrinters;
DWORD            cReturned, i;
 
 EnumPrinters (dwFlags, NULL, 2, NULL, 0, &cbPrinters,&cReturned);
 
 if (!(pPrinters = (LPPRINTER_INFO_2) LocalAlloc (LPTR, cbPrinters + 4)))
  return false;
 
 if (!EnumPrinters (dwFlags, NULL, 2, (LPBYTE) pPrinters,
  cbPrinters, &cbPrinters, &cReturned))
 {
  LocalFree (LocalHandle (pPrinters));
  return false;
 }
 
 if (cReturned > 0)
 {
  for (i = 0; i < cReturned; i++)
  {
   AfxMessageBox((pPrinters + i)->pPrinterName);
   if(strstr((pPrinters + i)->pPrinterName,"PDF")!=0 && strstr((pPrinters + i)->pPrinterName,"Writer")<=0)
   {
    m_sNewPrinter = "Adobe PDF";
    return true;
   }
  }
  for (i = 0; i < cReturned; i++)
  {
   if(strstr((pPrinters + i)->pPrinterName,"Acrobat Distiller")!=0 && m_sNewPrinter==""){  
    m_sNewPrinter = "Acrobat Distiller";
    return true;
   }
  }
 }
 
 LocalFree (LocalHandle (pPrinters));
 return false;
阅读全文
0 0

相关文章推荐

img
取 消
img