看API描述,不怎么理解,还是在网上找到用法,记载一下:
1: DWORD dwNeeded = 0, dwNum = 0;
2: EnumPrinters(PRINTER_ENUM_LOCAL, NULL, 4, NULL, 0, &dwNeeded, &dwNum);
3: BYTE* pBuffer = new BYTE[dwNeeded];
4: EnumPrinters(PRINTER_ENUM_LOCAL, NULL, 4, pBuffer, dwNeeded, &dwNeeded, &dwNum);
5: if(dwNum !=0 ) {
6: PRINTER_INFO_4* pPrnInfo = (PRINTER_INFO_4*) buffer;
7: for(int i=0; i<dwNum; i++) {
8: MessageBox(pPrnInfo->pPrinterName);
9: pPrnInfo++;
10: }
11: }
12: delete[] pBuffer;