Home General

How to detect if default printer connected

edited August 2001 in General
I am tired of getting AVs from Report Builder when the default printer is
not connected. I want to write some code to detect if the default printer is
connected and alert the user. I looked at TPrinter - but it I don't see a
way. I tried printer.begindoc and that works (generates an error if no
printer) - however it produces a dialog box if successful). What I want is
to run a check behind the scenes when the app starts up.
Any suggestions?

G

Comments

  • edited August 2001
    Hi Gerald,

    you can use the Windows-API functions, but that's really funny stuff, they
    changed it with every OS.
    Chaos par excellence!
    See AddPrinter, DeletePrinter, GetPrinter, GetProfileString, PRINTER_INFO_1,
    PRINTER_INFO_2, PRINTER_INFO_4, PRINTER_INFO_5, SetPrinter.
    I would inform the user that they have to have a default printer.

    regards,
    Chris Ueberall;

    is
  • edited August 2001
    > you can use the Windows-API functions, but that's really funny stuff, they
    PRINTER_INFO_1,


    several different clients with my laptop and so on a daily basis my network
    settings can change, as do the printers. Quite often I do not check the
    printer to see what I last set as the default. I am then busy developing for
    a week or so, forget about the RBuilder printer AV problem, and start
    getting these weird error messages such as cannot print on canvas etc. After
    about 15 to 30 nervewracking minutes of trying to figure it out I finally
    remember - oh! I should check the printer setting. Yesterday (the fourth
    time this has happened this year) I decided I am going to write a utility to
    check this!
This discussion has been closed.