dotnet-Snippets.com
Snippets: 57 | Registered User: 27 | Visitors online: 8
Main Menu

Home
Random Snippet
FAQs
Contact Us
Imprint
RSS Feeds

Rss All languages
Rss C#
Rss VB.NET
Rss C++
Rss J#
Rss ASP.NET
Google Ads

Sri Lanka .NET 
                Forum Member
Check if the printer is online

Author: Jan Welker
Programming Language: C# Rating:
not yet rated

Views: 209

Description:

Check if the printer is online



C#
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
using System.Drawing.Printing;

/// <summary>
/// Checks the printer.
/// </summary>
/// <param name="printerName">The printername.</param>
/// <returns></returns>
private bool CheckPrinter(string printerName)
{
    bool online = false;
    try
    {
        PrintDocument printDocument = new PrintDocument();
        printDocument.PrinterSettings.PrinterName = printerName;
        online = printDocument.PrinterSettings.IsValid;
    }
    catch
    {
        online = false;
    }
    return online;
}

This Snippets could be interesting for you:
No results available

Poor Excellent
1 2 3 4 5 6 7 8 9 10
Sign in to vote for this snippet.

Comments:
(Please log in to wrtite an comment.)