< prev index next >

src/java.desktop/windows/native/libawt/windows/awt_PrintControl.cpp

Print this page




 113     DWORD cReturned = 0;
 114 
 115     if (pPrinterEnum == NULL) {
 116         // Compute size of buffer
 117         DWORD cbNeeded = 0;
 118         ::EnumPrinters(PRINTER_ENUM_LOCAL | PRINTER_ENUM_CONNECTIONS,
 119                            NULL, 2, NULL, 0, &cbNeeded, &cReturned);
 120         ::EnumPrinters(PRINTER_ENUM_LOCAL,
 121                        NULL, 5, NULL, 0, pcbBuf, &cReturned);
 122         if (cbNeeded > (*pcbBuf)) {
 123             *pcbBuf = cbNeeded;
 124         }
 125         return TRUE;
 126     }
 127 
 128     DASSERT(printerName != NULL);
 129 
 130     DWORD cbBuf = *pcbBuf, dummyWord = 0;
 131 
 132     JavaStringBuffer printerNameBuf(env, printerName);
 133     LPCTSTR lpcPrinterName = (LPCTSTR)printerNameBuf;
 134     DASSERT(lpcPrinterName != NULL);
 135 
 136     // For NT, first do a quick check of all remote and local printers.
 137     // This only allows us to search by name, though. PRINTER_INFO_4
 138     // doesn't support port searches. So, if the user has specified the
 139     // printer name as "LPT1:" (even though this is actually a port
 140     // name), we won't find the printer here.
 141     if (!::EnumPrinters(PRINTER_ENUM_LOCAL | PRINTER_ENUM_CONNECTIONS,
 142                         NULL, 4, pPrinterEnum, cbBuf, &dummyWord, &cReturned)) {
 143         return FALSE;
 144     }
 145 
 146     for (DWORD i = 0; i < cReturned; i++) {
 147         PRINTER_INFO_4 *info4 = (PRINTER_INFO_4 *)
 148             (pPrinterEnum + i * sizeof(PRINTER_INFO_4));
 149         if (info4->pPrinterName != NULL &&
 150             _tcsicmp(lpcPrinterName, info4->pPrinterName) == 0) {
 151 
 152             // Fix for BugTraq Id 4281380.
 153             // Get the port name since some drivers may require




 113     DWORD cReturned = 0;
 114 
 115     if (pPrinterEnum == NULL) {
 116         // Compute size of buffer
 117         DWORD cbNeeded = 0;
 118         ::EnumPrinters(PRINTER_ENUM_LOCAL | PRINTER_ENUM_CONNECTIONS,
 119                            NULL, 2, NULL, 0, &cbNeeded, &cReturned);
 120         ::EnumPrinters(PRINTER_ENUM_LOCAL,
 121                        NULL, 5, NULL, 0, pcbBuf, &cReturned);
 122         if (cbNeeded > (*pcbBuf)) {
 123             *pcbBuf = cbNeeded;
 124         }
 125         return TRUE;
 126     }
 127 
 128     DASSERT(printerName != NULL);
 129 
 130     DWORD cbBuf = *pcbBuf, dummyWord = 0;
 131 
 132     JavaStringBuffer printerNameBuf(env, printerName);
 133     LPTSTR lpcPrinterName = (LPTSTR)printerNameBuf;
 134     DASSERT(lpcPrinterName != NULL);
 135 
 136     // For NT, first do a quick check of all remote and local printers.
 137     // This only allows us to search by name, though. PRINTER_INFO_4
 138     // doesn't support port searches. So, if the user has specified the
 139     // printer name as "LPT1:" (even though this is actually a port
 140     // name), we won't find the printer here.
 141     if (!::EnumPrinters(PRINTER_ENUM_LOCAL | PRINTER_ENUM_CONNECTIONS,
 142                         NULL, 4, pPrinterEnum, cbBuf, &dummyWord, &cReturned)) {
 143         return FALSE;
 144     }
 145 
 146     for (DWORD i = 0; i < cReturned; i++) {
 147         PRINTER_INFO_4 *info4 = (PRINTER_INFO_4 *)
 148             (pPrinterEnum + i * sizeof(PRINTER_INFO_4));
 149         if (info4->pPrinterName != NULL &&
 150             _tcsicmp(lpcPrinterName, info4->pPrinterName) == 0) {
 151 
 152             // Fix for BugTraq Id 4281380.
 153             // Get the port name since some drivers may require


< prev index next >