Solved

How to save and restore printer properties

Posted on 1997-06-18
1
257 Views
Last Modified: 2012-05-04
Before I start a print job I can select in a common dialog box the printer for the job and next I can set properties like Page size, Graphic resolution, Print quality, Dithering etc. in the Printer setup dialog box.

Who can tell me how to save these settings in a file or database, so that I can restore the settings the next time I start my program again to do another print job?

I have to do this in my Delphi 3 program for Windows 95,

Thanks in advance!

André Wolff

wolff@worldonline.nl

0
Comment
Question by:AndreWolff
1 Comment
 
LVL 1

Accepted Solution

by:
Gabor earned 100 total points
ID: 1337188
Here are the codes:type
  TPChar = array[0..150] of Char;
function SaveSettings(p: TPrinter; fs: TStream): Boolean;{the result shows the success}
var
  ADevice,ADriver,APort: TPChar;
  ADeviceMode: THandle;
  Size: LongInt;
begin
  p.GetPrinter(ADevice, ADriver, APort, ADeviceMode);
  result:=ADeviceMode<>0;

  if result then begin
    Size:=GlobalSize(ADeviceMode);
    fs.Write(ADevice,SizeOf(TPChar));
    fs.Write(ADriver,SizeOf(TPChar));
    fs.Write(APort,SizeOf(TPChar));
    fs.Write(Size,SizeOf(Size));
    fs.Write(Ptr(ADeviceMode,0)^,Size);
  end;
end;
procedure LoadSettings(p: TPrinter; fs: TStream);
var
  ADevice,ADriver,APort: TPChar;
  ADeviceMode: THandle;
  Size: LongInt;
begin
  fs.Read(ADevice,SizeOf(TPChar));
  fs.Read(ADriver,SizeOf(TPChar));
  fs.Read(APort,SizeOf(TPChar));
  fs.Read(Size,SizeOf(Size));
  ADeviceMode:=GlobalAlloc(HeapAllocFlags or GMEM_ZEROINIT,Size);
  if ADeviceMode<>0 then fs.Read(Ptr(ADeviceMode,0)^,Size);
  p.SetPrinter(ADevice,ADriver,APort,ADeviceMode);
end;
Good luck!
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now