Chang Printer Driver Settings

I need to change some settings on a couple printer drivers.  Right now these settings are not persistent and we have to open the printer dialog (using Delphi's printer dialog control) and manually change the settings EVERY time we run the program.  It's a huge pain.  Is there any way to make these changes programmatically?  This is a very big deal for my company (we are talking about printing out thousands of items a day).  Thanks for any help.
pswensonAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

IndefreiCommented:
Try
Demos with sources at
www.beyersdorf.com
Shows values returned by GetDeviceCaps Windows API function
and how to handle them
maybe, it helps a little bit
cheers
Indi
0
IndefreiCommented:
Heiii, as far as i know Ex-Ex and their knowledge about printer
driver problems, i should give it as an answer
if it's not satisfying you can reject my answer of course
regards
Indi
0
pswensonAuthor Commented:
Yeah, I'm aware of GetDeviceCaps.  But I was looking for specifics on how to parse the settings and change them.
0
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

rwilson032697Commented:
Here's a sample that changes the paper bin on the fly:

procedure TForm1.Button1Click(Sender: TObject);var
  ADevice, ADriver, APort: array [0..255] of char;  ADeviceMode: THandle;
  DevMode: PDevMode;begin    with Printer do begin
      GetPrinter(ADevice,ADriver,APort,ADeviceMode);
      SetPrinter(ADevice,ADriver,APort,0);
      GetPrinter(ADevice,ADriver,APort,ADeviceMode);
      DevMode := GlobalLock(ADeviceMode);
      if not Assigned(DevMode) then ShowMessage('Can''t set printer.')
      else begin        with DevMode^ do begin
          {Put any other settings you want here}
          dmDefaultSource := DMBIN_UPPER;
         {these codes are listed in "Windows.pas"}        end;
        GlobalUnlock(ADeviceMode);
        SetPrinter(ADevice,ADriver,APort,ADeviceMode);      end;    end;
    Printer.BeginDoc;
    Printer.Canvas.TextOut(50,50,'This page is printing from the UPPER PAPER TRAY.');
    with DevMode^ do begin      {Put any other settings you want here}
      dmDefaultSource := DMBIN_LOWER;
     {these codes are listed in "Windows.pas"}    end;
    Printer.NewPageDC(DevMode);
    Printer.Canvas.TextOut(50,50,'This page is printing from the LOWER PAPER TRAY.');
    Printer.EndDoc;end;


Here's the TDevMode structure with all the things you can change like this:

  _devicemodeA = packed record
    dmDeviceName: array[0..CCHDEVICENAME - 1] of AnsiChar;
    dmSpecVersion: Word;
    dmDriverVersion: Word;
    dmSize: Word;
    dmDriverExtra: Word;
    dmFields: DWORD;
    dmOrientation: SHORT;
    dmPaperSize: SHORT;
    dmPaperLength: SHORT;
    dmPaperWidth: SHORT;
    dmScale: SHORT;
    dmCopies: SHORT;
    dmDefaultSource: SHORT;
    dmPrintQuality: SHORT;
    dmColor: SHORT;
    dmDuplex: SHORT;
    dmYResolution: SHORT;
    dmTTOption: SHORT;
    dmCollate: SHORT;
    dmFormName: array[0..CCHFORMNAME - 1] of AnsiChar;
    dmLogPixels: Word;
    dmBitsPerPel: DWORD;
    dmPelsWidth: DWORD;
    dmPelsHeight: DWORD;
    dmDisplayFlags: DWORD;
    dmDisplayFrequency: DWORD;
    dmICMMethod: DWORD;
    dmICMIntent: DWORD;
    dmMediaType: DWORD;
    dmDitherType: DWORD;
    dmICCManufacturer: DWORD;
    dmICCModel: DWORD;
    dmPanningWidth: DWORD;
    dmPanningHeight: DWORD;
  end;

Hope this helps,

Cheers,

Raymond.

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
IndefreiCommented:
Hei
pswenson,
if this is really betterfor you, let me know
Raymond, you're really somethng like a delphi monster
(as far as you remember the demolished discussion
about printer problems)
I see, you are still learning
and that's fine of course
H.a.n.d
Indi
0
rwilson032697Commented:
Hi Indy,

I'm not sure what you mean by "Delphi monster", but I'll take it as a compliment!

I don't remember a demolished discussion about printer problems though...

For the record, the code snippet came from UDDF, and the record structure from windows.pad...

h.a.n.d = have a nice day?

Cheers,

Raymond.
0
men xinCEOCommented:
you can put a printdialog component and
setup it's properties.of couse,you neednt excute it.

BTW:which setting are you want to change.
0
IndefreiCommented:
Raymond,

>> "Delphi monster", but I'll take it as a compliment!
That`s right.

>>discussion about printer problems
some printer often did not print images etc.

h.a.n.d = have a nice day !

Indi

0
IndefreiCommented:
0
pswensonAuthor Commented:
When I get a chance I'll evaluate the answer...may be a bit.  I'm working on about 8 projects right now!
0
IndefreiCommented:
It's really a problem, that printer problems ALLWAYS
get stuck here at EX-EX
I'd like to see a helpful hand, too
Indi
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.