CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 1999
    Location
    Bangalore, India
    Posts
    21

    To Check If The Printer Is Connected

    Hi,
    When I give printer.print and if the printer is not set properly , it throws an error. Is there a way to check if the printer is ready for printing using APIs.
    I tried using OpenPrinter and GetPrinter. But some where I am doing something wrong.
    Please help.
    Thanks
    Arjun

    Software Engineer
    Bangalore

  2. #2
    Guest

    Re: To Check If The Printer Is Connected

    Arjun.
    You could simply put the following in a function

    public function Checkprinter() as boolean
    on error GoTo Printererr:
    Dim printername as string
    printername = Printer.DeviceName
    CheckPrinter=true
    Exit function
    Printererr:
    If Err.Number = 484 then
    'Printer Not Installed Correctly
    CheckPrinter=false
    else
    MsgBox Err.Number & " " & Err.Description
    End If
    end function



    Hope This Helps


  3. #3
    Join Date
    Sep 1999
    Location
    Bangalore, India
    Posts
    21

    Re: To Check If The Printer Is Connected

    Hi,
    The problem with the solution suggested is that
    1. If the printer is connected on a network computer (ie when trying to print form your system by connecting to a different computer's printer) this will throw an error, while if we give a print in word, the document is printed properly
    2. Delete an existing printer and then when I try this(without reebooting the system), it is retreving the printer name and doesn't throw an error. But when you give a prin command now from word, word shows a printer error.
    Thanks
    Arjun

    Software Engineer
    Bangalore

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