Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. programmatically check current (or selected) printer is dot-matrix printer, InkJet or Laser ?

programmatically check current (or selected) printer is dot-matrix printer, InkJet or Laser ?

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    ana_v123
    wrote on last edited by
    #1

    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

    L D 2 Replies Last reply
    0
    • A ana_v123

      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

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      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)

      1 Reply Last reply
      0
      • A ana_v123

        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

        D Offline
        D Offline
        David Crow
        wrote on last edited by
        #3

        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

        A 1 Reply Last reply
        0
        • D David Crow

          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

          A Offline
          A Offline
          ana_v123
          wrote on last edited by
          #4

          If I add printers (just available drivers of printers in Windows XP), it allows to many of the queries even if printer is not available physically. So I will surely try if I can find something to identify printer type for sure. Ana

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups