[C++] 纯文本查看 复制代码 HANDLE hPrinter;
TCHAR szPrinterName[] = _T("打印机名称~");
OpenPrinter(szPrinterName, &hPrinter, NULL);
DWORD dwNeeded = 0;
GetPrinter(hPrinter, 2, NULL, 0, &dwNeeded);
PRINTER_INFO_2* pPrinterInfo = (PRINTER_INFO_2*)malloc(dwNeeded);
if (pPrinterInfo)
{
if (GetPrinter(hPrinter, 2, (LPBYTE)pPrinterInfo, dwNeeded, &dwNeeded))
{
_tprintf(_T("Printer Name: %s\n"), pPrinterInfo->pPrinterName);
_tprintf(_T("Driver Name: %s\n"), pPrinterInfo->pDriverName);
_tprintf(_T("Port Name: %s\n"), pPrinterInfo->pPortName);
}
free(pPrinterInfo);
}
ClosePrinter(hPrinter);
|