Identifying Printer Model

This is a discussion on Identifying Printer Model within the Windows Programming forums, part of the Platform Specific Boards category; What I want to do is detect a certain model of printer, but currently the only way of seeing what ...

  1. #1
    Registered User
    Join Date
    Sep 2008
    Posts
    33

    Identifying Printer Model

    What I want to do is detect a certain model of printer, but currently the only way of seeing what printer it is that I know of is using the DEVMODE struct which contains the device name. The problem with that of course is you can name your printer whatever you want, so using the name to identify it is not a great method.

    However, even if you change its name Windows can still identify the model correctly, so obviously it is possible.

    I have been looking at the GetPrinterDriver functions on MSDN and the DRIVER_INFO structs, but don't know if this is the right way to go about it. (That, and the fact that I can't really figure out how to implement them)

    Any hints/tips/suggestions are appreciated.

  2. #2
    Registered User
    Join Date
    Sep 2008
    Posts
    33
    Never mind I figured it out. For anyone wondering, this is how I went about it:

    Code:
    HANDLE hPrinter=NULL;
    DWORD dwBytesNeeded=0;
    PRINTER_INFO_2* pinfo2=NULL;
    
    	
    if (OpenPrinter(name.c_str(), &hPrinter, NULL))
    {
    	GetPrinter(hPrinter, 2, NULL, NULL, &dwBytesNeeded);
    	pinfo2 = (PRINTER_INFO_2*) LocalAlloc(LPTR, dwBytesNeeded);
    	GetPrinter(hPrinter, 2, (LPBYTE)pinfo2, dwBytesNeeded, &dwBytesNeeded);
    }
    and pinfo2 now has the driver info I was looking for. 'name' is a string of the name of the printer.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Set Printer Prior To Loading Print Dialog Box
    By Beaner in forum Windows Programming
    Replies: 3
    Last Post: 10-10-2008, 01:02 PM
  2. Replies: 14
    Last Post: 06-28-2006, 01:58 AM
  3. changing property (layout) of a printer
    By leojose in forum Windows Programming
    Replies: 5
    Last Post: 12-05-2005, 06:16 AM
  4. Help with file reading/dynamic memory allocation
    By Quasar in forum C++ Programming
    Replies: 4
    Last Post: 05-17-2004, 03:36 PM
  5. Success - Output to Printer
    By noraa in forum C Programming
    Replies: 5
    Last Post: 08-04-2002, 09:12 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21