473,396 Members | 1,998 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,396 software developers and data experts.

How to get HDC object of Printer

Since I need to call Windows API GetDeviceCaps() in C#, I must get HDC
object of printer. And I don't like to receive the PrintPage Event because I
don't
want to print the page, just to get some properties. How can I get it? Thank
you!

Jerry
Nov 16 '05 #1
3 8643
Jerry,

In order to get the DC of the printer, you will have to call the
CreateDC function through the P/Invoke layer. You can pass the display name
of the printer to the lpszDevice parameter.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"°Ë´óɽÈË" <zh**********@hotmail.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Since I need to call Windows API GetDeviceCaps() in C#, I must get HDC
object of printer. And I don't like to receive the PrintPage Event because I don't
want to print the page, just to get some properties. How can I get it? Thank you!

Jerry

Nov 16 '05 #2
Hi, can you tell me how to pass the parameter lpzsDriver?

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:%2****************@TK2MSFTNGP12.phx.gbl...
Jerry,

In order to get the DC of the printer, you will have to call the
CreateDC function through the P/Invoke layer. You can pass the display name of the printer to the lpszDevice parameter.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"°Ë´óɽÈË" <zh**********@hotmail.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Since I need to call Windows API GetDeviceCaps() in C#, I must get HDC
object of printer. And I don't like to receive the PrintPage Event
because I
don't
want to print the page, just to get some properties. How can I get it?

Thank
you!

Jerry


Nov 16 '05 #3
"°Ë´óɽÈË" wrote :
Hi, can you tell me how to pass the parameter lpzsDriver?


[DllImport("gdi32.dll")]
static extern IntPtr CreateDC(string lpszDriver, string lpszDevice, string
lpszOutput, IntPtr lpInitData);
IntPtr dc = CreateDC("WINSPOOL", "deviceName", null, IntPtr.Zero);
To have a look at the parameters values :

http://msdn.microsoft.com/library/de...vcons_5g83.asp

--
Francois Beaussier
Fr******@3ie.org.remove
Nov 16 '05 #4

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

Similar topics

5
by: Tom Berry | last post by:
We currently are trying our first transformation from VB6 to VB.Net. Of course, the Printer object is gone, but I'm having trouble finding the replacement syntax necessary to perform similar...
3
by: Rick Collard | last post by:
I have been experimenting with the new Printer object in Access 2002 and discovered some unexpected database bloat. Simply assigning the same value to a property of a report's Printer object will...
1
by: David Trivette | last post by:
I was wondering if anyone could help me with a MS Access 2002 issue I'm having. Problem - I created a db in Access 97 which worked just fine for several years. In the db the user can generate...
0
by: Karthik | last post by:
Well I am coding an application using C# for my company which requires multiple printing of Crystal Report Docs & Word Docs, at a specific Printer of the installed Printers in the network, at a...
1
by: Robin Dindayal | last post by:
Does anyone know how I can print a fully rendered .aspx to the server's printer? I know that, if I wanted to print to the client's printer it would be easy (ie. use javascript's window.print()). ...
2
by: Regis | last post by:
Hie, I'm converting a VB6 Application to VB.NET (architect 2003). In my VB6 Software, I'm using printer object to print directly to the printer port without having Windows font. What...
1
by: Sanjoy GuhaRoy via DotNetMonster.com | last post by:
I want to know what is the corresponding printer object of VB6 in VB.Net In VB 6 printer object was default and we could use it and call all its methods like 1.Printer.PaperSize...
3
by: Mika M | last post by:
Hi all! I have made an application for printing simple barcode labels using PrintDocument object, and it's working fine. Barcode printer that I use is attached to the computer, and this...
3
by: MLH | last post by:
Access 97 Q: Can I examine a report object property setting in VBA and tell whether the report is setup to print to a specific printer or to the windows default printer? You know, the setting...
0
by: Ravigwipro | last post by:
Hi, I m able to get the printers object to know what are the printers had been installed and all. here my requirement is i have to write a data from VB to MS Word. for the page setup i have to...
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.