Jul 23
programming / scripting

Diese Funktion durchläuft alle installierten Drucker und prüft, ob der angegeben Drucker existiert oder nicht.

  1.  
  2.  
  3. Imports System.Drawing.Printing''' <summary>
  4. ''' Prüft, ob der angegeben Drucker existiert.
  5. ''' </summary>
  6. ''' <param name="PrinterName">Druckername</param>
  7. ''' <returns>True, wenn der Drucker vorhanden ist, andernfalls False.</returns>
  8. Public Function PrinterExists(ByVal PrinterName As String) As Boolean
  9.   Try
  10.     ' alle installierten Drucker durchlaufen
  11.     For Each sPrinter As String In PrinterSettings.InstalledPrinters
  12.       If String.Compare(sPrinter, PrinterName, True) = 0 Then
  13.         Return True
  14.       End If
  15.     Next
  16.  
  17.     ' wenn Drucker nicht in der Auflistung enthalten...
  18.     Return False
  19.  
  20.   Catch ex As Exception
  21.     ' Fehler! Rückgabe: Drucker nicht gefunden
  22.     Return False
  23.   End Try
  24. End Function
  25.  

Posted by Alessandro Banzer

Twitter Facebook

0 Trackbacks

  1. No Trackbacks

1 Comments

Display comments as(Linear | Threaded)
  1. print10 says:

    Danke für die Hilfe!

Add Comment


Enclosing asterisks marks text as bold (*word*), underscore are made via _word_.
Standard emoticons like :-) and ;-) are converted to images.

To prevent automated Bots from commentspamming, please enter the string you see in the image below in the appropriate input box. Your comment will only be submitted if the strings match. Please ensure that your browser supports and accepts cookies, or your comment cannot be verified correctly.
CAPTCHA

You can use [geshi lang=lang_name [,ln={y|n}]][/geshi] tags to embed source code snippets.

Submitted comments will be subject to moderation before being displayed.