Solved

How to save and restore printer properties

Posted on 1997-06-18
1
263 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

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…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Suggested Courses
Course of the Month11 days, 15 hours left to enroll

623 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