Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How to save and restore printer properties

Posted on 1997-06-18
1
Medium Priority
?
270 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 300 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
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…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses

927 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