Newsgroups : Borland : borland.public.delphi.nativeapi.win32 : 2005 Feb : Forcing Generic mPrinter to Print to a file

www.cryer.info
Managed Newsgroup Archive

Forcing Generic mPrinter to Print to a file

Subject:Forcing Generic mPrinter to Print to a file
Posted by:"R. Michael Hall" (rmha..@mailinator.com)
Date:16 Feb 2005 06:18:16

I have an app that resets the default printer to Generic/Text Only and
sets it to print to a spcific file. This causes all other running app
to print to thsi file, which my program uses to parse data from. The
techniquie I uses is:

      StrCopy(GenericPrinter, 'Generic / Text Only,TTY,');
      // Create path and filename for printing
      StrPCopy(s, ProgDir);
      StrCat(GenericPrinter, s);
      StrCat(GenericPrinter, 'UNTITLED.TXT');

if Reg.OpenKey('\Software\Microsoft\Windows NT\CurrentVersion\Windows',
True)
    then
    begin
      try
        Reg.WriteString('Device', 'Generic/Text Only);
      except
        MessageDlg('Unable to write to \Software\Microsoft\Windows
NT\CurrentVersion\Windows', mtError, [mbOK], 0);
      end;                              // try..except
      Reg.CloseKey;
      Result := SendMessageTimeout(HWND_BROADCAST,
        WM_SETTINGCHANGE,
        0, 0, SMTO_BLOCK, 1000, lpdResult) <> 0;

This has always worked under Win NT but no longer works with WinXP.

I need to force the printing to the file without user intervention, ie
no file save dialog.

Does anyone have an idea how to do this under XP?

TIA

Mike

Replies:

www.cryer.info
Managed Newsgroup Archive