Printer control using win.ini

Printer control using win.ini

Post by Sandy Bittm » Wed, 13 Dec 1995 04:00:00



I am writing a MSVC++ process that uses WinExec() and a "macro" to
print some forms.  I need to print the form with both gl2 graphics and
raster graphics, and I am using WriteProfileString() to change the
printer profile in the win.ini file.

Problem:  The profile is not changing!

Wrong Solution:  If I re-boot windows between prints, the new profile
changes take effect.  Needless to say, this defeats the purpose of
automating the process.

HELP:  As I understand it, Microsoft is now caching the printer
profiles seperately since windows 3.1.  How do I force windows, and the
printer drivers, to re-read the .ini file?  Or, is there another method
of changing the printer profiles under program control?

Thanks for any help I can get :-)

    Sandy

 
 
 

Printer control using win.ini

Post by John Gra » Thu, 14 Dec 1995 04:00:00



>I am writing a MSVC++ process that uses WinExec() and a "macro" to
>print some forms.  I need to print the form with both gl2 graphics and
>raster graphics, and I am using WriteProfileString() to change the
>printer profile in the win.ini file.

>Problem:  The profile is not changing!

>Wrong Solution:  If I re-boot windows between prints, the new profile
>changes take effect.  Needless to say, this defeats the purpose of
>automating the process.

>HELP:  As I understand it, Microsoft is now caching the printer
>profiles seperately since windows 3.1.  How do I force windows, and the
>printer drivers, to re-read the .ini file?  Or, is there another method
>of changing the printer profiles under program control?

>Thanks for any help I can get :-)

>    Sandy

        I am not exactly sure what you mean by WinExec() & a 'macro',
        but here is some general information about accessing printer
        settings.

        Your application should NOT change the printer settings in
        win.ini.  Try this. Start up notepad, switch to a printer other than
        the default printer and print something. Now shut it down and
        start it up again.  Check the default printer - it hasn't changed,
        has it?  No, that's because the application didn't modify the
        win.ini file.  It used the selected printer as a 'local' setting
        and discarded it when it terminated.  This is the way all apps
        should work.

        I get *really* annoyed at applications which change my default
        printer settings, so that I have go back to control panel
        and reset them.  I think an older version of PaintShop Pro
        did this.

        Your application should allow the user to select a printer for
        the purpose of printing from that application only, but it should
        not change the default printer setting.  The old way to get
        printer info was to 'read' win.ini.  The modern way is to call
        the COMMDLG.DLL PrintDlg() function.  You can call it with
        PD_RETURNDC to return an HDC to you and/or you can call it
        in a non-interactive way with PD_RETURNDEFAULT.
--

Airborne Geophysics
Geological Survey of Canada, Ottawa

 
 
 

Printer control using win.ini

Post by Helge-Wernhard Sue » Thu, 14 Dec 1995 04:00:00



Quote:>I am writing a MSVC++ process that uses WinExec() and a "macro" to
>print some forms.  I need to print the form with both gl2 graphics and
>raster graphics, and I am using WriteProfileString() to change the
>printer profile in the win.ini file.

>Problem:  The profile is not changing!

Look up WM_WININICHANGE

Helge ;-)=)

----------------------------------------------------------
      (c) All Thoughts are Mine -- Genuine Genius
----------------------------------------------------------

----------------------------------------------------------

 
 
 

Printer control using win.ini

Post by John Gra » Thu, 14 Dec 1995 04:00:00




>>        Your application should NOT change the printer settings in
>>        win.ini.  

>  I've yet to come up with a way to do the following _without_ having to
>  change WIN.INI:

>  My app prints its stuff, then it prints 'attachments' using their
>  associated apps, ie ShellExecute(..."FILE.EXT", "print", ...);

>  Problem: Application prints to user-selected printer, attachments get
>           printed on the default printer. Not good.

>  Current solution: Change default printer in WIN.INI, broadcast WM_WININICHANGE,
>           print attachments, change WIN.INI back, broadcast WM_WININICHANGE.

>  Welcomed: Better solution.

>-zi

        Ok. I misunderstood the original question.  I can't come up with
        any better solution.
--

Airborne Geophysics
Geological Survey of Canada, Ottawa