CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Feb 2003
    Posts
    5

    Reading printer model name

    Hi,

    I'm looking for some sample code (VBA97 or VB6) for reading the model (driver?) name of a printer (the default printer would be fine).

    The ActivePrinter property gives me <printer path> on <port>, but what I am after is the model name that the driver provides (as in the 'General' tab of the printer properties).

    It seems possible in VBA XP (I think the driverName property can be used), but I'm stuck for VBA 97/VB6...

    I've thought of using the HKLM\System\CurrentControlSet\Print\Printers\Default registry settings, but this doesn't appear to get updated when I set a default printer (in WinXP, anyway).

    Any help would be greatly appreciated!!!

    Thanks,

    Iain

  2. #2
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    Have you tried devicename of printer object?

    try:
    MsgBox Printer.DeviceName

    Hope it helps
    Cesare I.
    ...at present time, using mainly Net 4.0, Vs 2010



    Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
    all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

  3. #3
    Join Date
    Dec 1999
    Location
    Dublin, Ireland
    Posts
    1,173
    Server Name, Printer Name and Driver name are all part of the PRINTER_INFO_2 structure that you can get using the API call GetPrinter as per this article
    '--8<-----------------------------------------
    NEW -The printer usage monitoring application
    '--8<------------------------------------------

  4. #4
    Join Date
    Feb 2003
    Posts
    5
    The printer.devicename gives you the same as ActivePrinter does in VBA. I guess this is OK for locally-attached printers but for network ones it gives you somethine like

    \\server\printer on NE01:

    What I was after was the actual model of the printer, something like:

    HP LaserJet 5M

    (I have my reasons!)

    Anyway, I think I've found a solution - and it was to use the registry keys for the printers, found within CurrentControlSet.

    The attached Word (97) file should explain all this. It is an amalgam of a lot of different idea that I have tried, so it is very poorly commented, and there may be a lot of redundant code!!! A lot of it has come from other sample code - for example MSDN article Q143274 and Jonathan West's series on controlling printers within VB. Thank you for your help!!!


    Iain
    Attached Files Attached Files

  5. #5
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    Thumbs up Always nice...

    ...to learn;
    thanks for sharing.

    Cesare I.
    ...at present time, using mainly Net 4.0, Vs 2010



    Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
    all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

  6. #6
    Join Date
    Jul 2005
    Posts
    19

    Re: Reading printer model name

    Hi all,

    I want to know the model name of the printer not the driver name installed on it. The sample shared is giving the name of the driver not the model name. Is there any way to get the printer model name?

    Thanks
    Inar

  7. #7
    Join Date
    Jun 2005
    Location
    Orissa
    Posts
    150

    Re: Reading printer model name

    check the link, which direct to the answer posted at VBForums.com

    Hope, this will help.

    [Link]
    http://www.vbforums.com/showthread.php?t=111383
    [/Link]
    Thanks and Regards

    "Always Praise for the good work served"

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured