GdPicture.NET.14
GdPicture14 Namespace / GdViewer Class / PrintGetPrintersCount Method
Example





In This Topic
PrintGetPrintersCount Method (GdViewer)
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.
'We assume that the GdViewer1 control has been properly integrated.
Dim PrintersCount As Integer = GdViewer1.PrintGetPrintersCount()
If GdViewer1.GetStat() = GdPictureStatus.OK Then
    Dim CurPrinter As String = GdViewer1.PrintGetActivePrinter()
    If GdViewer1.GetStat() = GdPictureStatus.OK Then
        MessageBox.Show("The number of available printers: " + PrintersCount.ToString() + vbCrLf + "The currently active printer is: " + CurPrinter, "GdViewer.PrintGetPrintersCount")
    Else
        MessageBox.Show("The PrintGetActivePrinter() method has failed with the status: " + GdViewer1.PrintGetStat(), "GdViewer.PrintGetPrintersCount")
    End If
Else
    MessageBox.Show("The PrintGetPrintersCount() method has failed with the status: " + GdViewer1.PrintGetStat(), "GdViewer.PrintGetPrintersCount")
End If
//We assume that the GdViewer1 control has been properly integrated.
int PrintersCount = GdViewer1.PrintGetPrintersCount();
if (GdViewer1.GetStat() == GdPictureStatus.OK)
{
    string CurPrinter = GdViewer1.PrintGetActivePrinter();
    if (GdViewer1.GetStat() == GdPictureStatus.OK)
        MessageBox.Show("The number of available printers: " + PrintersCount.ToString() +
                        "\nThe currently active printer is: " + CurPrinter, "GdViewer.PrintGetPrintersCount");
    else
        MessageBox.Show("The PrintGetActivePrinter() method has failed with the status: " + GdViewer1.PrintGetStat(), "GdViewer.PrintGetPrintersCount");
}
else
    MessageBox.Show("The PrintGetPrintersCount() method has failed with the status: " + GdViewer1.PrintGetStat(), "GdViewer.PrintGetPrintersCount");
See Also