Creating a C# application to configure printer page settings
I am looking to deploy a c# application at my workplace which defines the default paper size. Nothing too special. It works by calling windows.win32 and using the registry class to write to the registry.
Despite my best efforts, I have been unable to find the relevant registry entries in order to set the paper size and registered printers. Can anyone help?
Cheers开发者_JAVA百科!
Changing registry settings is not the supported way to do this.
The correct way is to use the DEVMODE
structure.
The remarks at the bottom of the DocumentProperties
function describe the correct way to merge a new setting (such as paper size) with the existing configuration.
Don't worry that it describes how to change the settings for your application. Replace the last step (CreateDC
) with calling the SetPrinter
function at level 8 to change the global defaults for that printer (or use level 9 to change the per-user defaults).
Doing this would be much easier in C++, since you can use the Windows-provided header files. The structures involved are very complex, and getting the right p/invoke definitions would be extremely difficult.
I dont think that the settings you want exist.
I found this
I don't know about the general settings.My guess it depends on application and driver you use. At least I know for sure that some printer drivers have their own default settings (hard-coded or set in registry). Some settings are set through *.ppd files.
Here is IE printer settings you can play with:
[HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings]
Value : type Description PageOrientation : REG_DWORD Specifies page orientation. Valid settings are 1=portrait, 2=landscape. Default setting is 1. PrintQuality : REG_DWORD Specifies print quality. Valid settings are 1=draft, 2=final. Default setting is 1. PaperSize : REG_DWORD Specifies paper size. Valid settings are 1=letter, 5=Legal, 9=A4, 13=B5.Default setting is 1.
http://www.pcreview.co.uk/forums/settings-dafault-paper-size-registry-t528995.html
The usual way to change printer parameters is through the Win32 DEVMODE
structure during the printing process. The driver itself is responsible for filling in the defaults, and is generally configured through its property page.
精彩评论