|
地板
楼主 |
发表于 2023-5-16 22:26:57
|
只看该作者
能否帮忙封一下,或者指导一下
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); |
|