Solved

How to save and restore printer properties

Posted on 1997-06-18
1
259 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

749 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