Solved

How to save and restore printer properties

Posted on 1997-06-18
1
252 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
Comment Utility
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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

762 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