Setting a Default Printer Driver in a Stand-Alone .EXE

Last reviewed: April 17, 1995
Article ID: Q99909
The information in this article applies to:
  • Microsoft FoxPro for MS-DOS, versions 2.0 and 2.5

SUMMARY

By default, a stand-alone .EXE file cannot use the default printer driver setup. This is because the support libraries built into the executable file do not contain all the printer driver information. To create a stand-alone .EXE file that can use a default printer driver, either create a compact executable file or use the program below.

MORE INFORMATION

To create a stand-alone .EXE file that can use the default printer driver setup, place the following code at the top of the main program file in the .EXE file. Make sure GENPD.APP is included in the project and marked as Excluded.

This program searches the FoxUser file for a default printer driver, and if there is no default driver available, a dialog box to select a printer driver appears.

   mresource = SYS(2005)    && Store current Resource file.
   SET RESOURCE OFF
   USE &mresource           && USE the Resource file.
   LOCATE FOR '-' $ name    && Search FoxUser for default printer.
   IF FOUND ()
      drvr = substr(name,2,LEN(name)-1)   && Store default printer
                                          &&   driver to drvr.
      USE                   && Close Resource file.
      SET RESOURCE TO &mresource  && Set Resource on.
      SET PDSETUP TO drvr         && Set default printer driver.
   ELSE
      USE                         && Close Resource file.
      SET RESOURCE TO &mresource  && Set Resource on.
      SET PDSETUP TO "?"    && Allows selection of a printer driver.
   ENDIF


Additional reference words: FoxDos 2.00 2.50 standalone
KBCategory: kbprg kbcode
KBSubcategory:


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: April 17, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.