Example





In This Topic
GdPicture14 Namespace / GdPicturePDF Class / PrintGetPrintersCount Method

PrintGetPrintersCount Method (GdPicturePDF)

In This Topic
Returns the number of all available (installed) printers on the computer.
Syntax
'Declaration

 

Public Function PrintGetPrintersCount() As Integer
public int PrintGetPrintersCount()
public function PrintGetPrintersCount(): Integer; 
public function PrintGetPrintersCount() : int;
public: int PrintGetPrintersCount(); 
public:

int PrintGetPrintersCount(); 

Return Value

The number of available printers. The GetStat method can be subsequently used or the PrintGetStat method to determine if this method has been successful.
Remarks
It is recommend to use the GetStat method or the PrintGetStat method to identify the specific reason for the method's failure, if any.
Example
How to find out the number of currently installed printers on your computer.
Dim caption As String = "Example: PrintGetPrintersCount"

Using gdpicturePDF As New GdPicturePDF()

    Dim PrintersCount As Integer = gdpicturePDF.PrintGetPrintersCount()

    If gdpicturePDF.GetStat() = GdPictureStatus.OK Then

        Dim CurPrinter As String = gdpicturePDF.PrintGetActivePrinter()

        If gdpicturePDF.GetStat() = GdPictureStatus.OK Then

            MessageBox.Show("The number of available printers: " + PrintersCount.ToString() + vbCrLf +

                            "The currently active printer is: " + CurPrinter, caption)

        Else

            MessageBox.Show("The PrintGetActivePrinter() method has failed with the status: " + gdpicturePDF.PrintGetStat(), caption)

        End If

    Else

        MessageBox.Show("The PrintGetPrintersCount() method has failed with the status: " + gdpicturePDF.PrintGetStat(), caption)

    End If

End Using
string caption = "Example: PrintGetPrintersCount";

using (GdPicturePDF gdpicturePDF = new GdPicturePDF())

{

    int PrintersCount = gdpicturePDF.PrintGetPrintersCount();

    if (gdpicturePDF.GetStat() == GdPictureStatus.OK)

    {

        string CurPrinter = gdpicturePDF.PrintGetActivePrinter();

        if (gdpicturePDF.GetStat() == GdPictureStatus.OK)

            MessageBox.Show("The number of available printers: " + PrintersCount.ToString() +

                            "\nThe currently active printer is: " + CurPrinter, caption);

        else

            MessageBox.Show("The PrintGetActivePrinter() method has failed with the status: " + gdpicturePDF.PrintGetStat(), caption);

    }

    else

        MessageBox.Show("The PrintGetPrintersCount() method has failed with the status: " + gdpicturePDF.PrintGetStat(), caption);

}
See Also