programmatically check current (or selected) printer is dot-matrix printer, InkJet or Laser ?
-
On Windows XP/2000/NT as well as on Windows 98 How can we check programmatically whether current (or selected) printer is dot-matrix printer, InkJet or Laser ? (Because end-user of application may have any type of Printer) I appreciate any help or hint. Ana
-
On Windows XP/2000/NT as well as on Windows 98 How can we check programmatically whether current (or selected) printer is dot-matrix printer, InkJet or Laser ? (Because end-user of application may have any type of Printer) I appreciate any help or hint. Ana
wow, great question... I have never tried this before. The only thing I can think of... is getting the PRINTER_INFO_2 struct and checking the capabilities of the printer. First get the default printer.
HANDLE CPrinter::OpenDefaultPrinter(ACCESS_MASK dwMask) { HANDLE hPrinter = INVALID_HANDLE_VALUE; PRINTER_DEFAULTS pDef; DWORD dwSize; ZeroMemory(&pDef, sizeof(pDef)); GetDefaultPrinter(NULL, &dwSize); TCHAR* szBuffer = new TCHAR[dwSize]; if(NULL != szBuffer) { if(GetDefaultPrinter(szBuffer, &dwSize)) { pDef.DesiredAccess = dwMask; OpenPrinter(szBuffer, &hPrinter, &pDef); } delete szBuffer; } return hPrinter; }
Once you have the default printer... ou can populate a PRINTER_INFO_2 struct and look at all of the capabilities of the printer. I honestly dont know how to determine if a printer is dot matrix... but I have an idea... I would think a dot matrix printer would probably have very low settings... low resolution... ect Maybe something like this would work...HANDLE hPrinter = OpenDefaultPrinter(); if(INVALID_HANDLE_VALUE != hPrinter) { GetPrinter(hPrinter, 2, (LPBYTE)pInfo, 0, &dwNeeded); if(0 < dwNeeded) { pInfo = static_cast(GlobalAlloc(GPTR, dwNeeded)); if(NULL != pInfo) { if(GetPrinter(hPrinter, 2, (LPBYTE)pInfo, dwNeeded, &dwNeeded)) { // //CHECK PRINTER SETTINGS HERE... resolution... ect... // } } GlobalFree(pInfo); } ClosePrinter(hPrinter); }
Some other possibilities... DeviceCapabilities() in the MSDN: http://msdn2.microsoft.com/en-us/library/ms535506.aspx[^] Maybe by reading what the printer is capable of you can determine if it *might* be a dot matrix. I have never tried this, let me know if you have any success. -Randor (David Delaune) -
On Windows XP/2000/NT as well as on Windows 98 How can we check programmatically whether current (or selected) printer is dot-matrix printer, InkJet or Laser ? (Because end-user of application may have any type of Printer) I appreciate any help or hint. Ana
To elaborate on what Randor said, do you have access to the various types of printers? If so, write a small program to show the attributes/properties/capabilities of each and compare. Surely you would find a value with a dot matrix that would be different from the others, or some setting with a laser that would be different from the others.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
-
To elaborate on what Randor said, do you have access to the various types of printers? If so, write a small program to show the attributes/properties/capabilities of each and compare. Surely you would find a value with a dot matrix that would be different from the others, or some setting with a laser that would be different from the others.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne