Jul 23
programming / scripting

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

  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
  17.     ' wenn Drucker nicht in der Auflistung enthalten...
  18.     Return False
  20.   Catch ex As Exception
  21.     ' Fehler! Rückgabe: Drucker nicht gefunden
  22.     Return False
  23.   End Try
  24. End Function

Posted by Alessandro Banzer

Twitter Facebook

0 Trackbacks

  1. No Trackbacks


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.

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.