473,385 Members | 1,356 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Standarddrucker mit .Net ermitteln

Hallo Leute,

ich versuche seit langem eine Lösung für das Auslesen des
Standarddruckers zu finden. WMI, API,
System.Drawing.Printing.PrinterSettings habe ich alles schon versucht,
leider nicht zurfrieden stellend. Hat jemand eine saubere Lösung ffür
VB.Net oder C#???
Mit der Win-API habe ich z.B. versucht GetDefaultPrinter aufzurufen,
jedoch erscheint dann immer die Meldung "Es wurde versucht, im
geschützten Speicher zu lesen oder zu schreiben. Dies ist häufig ein
Hinweis darauf, dass anderer Speicher beschädigt ist." Was soll das?
Eine Lösung für dieses Problem habe ich noch nicht gefunden.
Code:
Das kann frusten :-((

Declare Function GetDefaultPrinter Lib "winspool.drv" Alias
"GetDefaultPrinterA" (ByRef pszBuffer As String, ByRef dwLen As
Integer) As Integer

Na ja wäre jedenfalls nett, wenn jemand einen Tip hätte.

Vielen Dank

May 8 '06 #1
4 7819
From what I gather, if you create a PrintSettings object it will
contain the settings for the default printer. Use the PrinterName
property to get the name of the default printer.

mreisi wrote:
Hallo Leute,

ich versuche seit langem eine Lösung für das Auslesen des
Standarddruckers zu finden. WMI, API,
System.Drawing.Printing.PrinterSettings habe ich alles schon versucht,
leider nicht zurfrieden stellend. Hat jemand eine saubere Lösung ffür
VB.Net oder C#???
Mit der Win-API habe ich z.B. versucht GetDefaultPrinter aufzurufen,
jedoch erscheint dann immer die Meldung "Es wurde versucht, im
geschützten Speicher zu lesen oder zu schreiben. Dies ist häufig ein
Hinweis darauf, dass anderer Speicher beschädigt ist." Was soll das?
Eine Lösung für dieses Problem habe ich noch nicht gefunden.
Code:
Das kann frusten :-((

Declare Function GetDefaultPrinter Lib "winspool.drv" Alias
"GetDefaultPrinterA" (ByRef pszBuffer As String, ByRef dwLen As
Integer) As Integer

Na ja wäre jedenfalls nett, wenn jemand einen Tip hätte.

Vielen Dank

May 10 '06 #2
"Göran Andersson" <gu***@guffa.com> schrieb:
From what I gather, if you create a PrintSettings object it will contain
the settings for the default printer. Use the PrinterName property to get
the name of the default printer.


In addition, check out 'PrinterSettings.IsDefaultPrinter'.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

May 10 '06 #3
Ja das habe ich auch schon ausprobiert, jedoch funktioniert das leider
nicht, wenn man den Standarddrucker kurz zuvor gewechselt hat. Trotzdem
Danke für den Tipp. Die MSDN sagt dazu folgendes:
"Ruft einen Wert ab, der angibt, ob die PrinterName-Eigenschaft immer
dann den Standarddrucker festlegt, wenn der Benutzer PrinterName nicht
explizit festlegt."
Das ist leider nicht wirklich die Lösung.

May 10 '06 #4
Ja das habe ich auch schon ausprobiert, jedoch funktioniert das leider
nicht, wenn man den Standarddrucker kurz zuvor gewechselt hat. Trotzdem
Danke für den Tipp. Die MSDN sagt dazu folgendes:
"Ruft einen Wert ab, der angibt, ob die PrinterName-Eigenschaft immer
dann den Standarddrucker festlegt, wenn der Benutzer PrinterName nicht
explizit festlegt."
Das ist leider nicht wirklich die Lösung.

May 10 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: teso | last post by:
Hallo Zusammen, Ich suche eine Möglichkeit Internet bzw. HTML Inhalte zu vergleichen. Mein Ansatz war den hashcode (URL.hashCode()) einer URL zu ermitteln und diesen zu vergleichen. Dazu habe...
4
by: Tom Vukovich | last post by:
Hi All, I have an application that I am porting from VB6 to VBNet and in vb6 i can detect the unloadMode. DotNet doesn't support this but I need the functionality. I understand the code should be in...
3
by: Klaus Löffelmann | last post by:
Hello, how can a console application get its startpath? The application-object doesn't apply for console applications, does it? Thanks Klaus
7
by: SStory | last post by:
Hi, I am building an explorer type interface for file selection Need to know how to determine what type of device a DRIVE is i.e. C: (harddisk) A: (floppy)
3
by: Giuseppe Pezzella | last post by:
Hi In Windows every file have yours icon, so: how I get them ( Extension and Icon) and save in a imageList for use later in a ListView? In VB6 was SHGetFileInfo. In VB.NET? How I can...
8
by: mreisi | last post by:
Hallo Leute, ich habe vor kurzem schon einmal das Thema gestartet, wie man den Standarddrucker unter .Net auslesen kann. Die API-Funktion GetDefaultPrinter() ist mir dabei über den Weg gelaufen,...
7
by: Peter Hansch | last post by:
Hallo, habe ein VS02 Projekt konvertiert auf VS05. Es handelt sich um eine Klasse zur erzeugung eines Screenshots Dabei tritt oben genannter Fehler auf an. Und zwar bei markierter Stelle: ...
2
by: kirstenkirsche | last post by:
Hi guys.... i know this question has been asked already and I found a few answers but it would be soo great if anyone could help me with this script, which just browses images on a webpage in an...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.