ImageGear for C and C++ on Windows v19.6 - Updated
Let the User Install and Select Drivers
User Guide > How to Work with... > Common Operations > Scanning > ISIS Scanning > Use ISIS Drivers > Let the User Install and Select Drivers

Many applications will need to give users the ability to select their scanner from among the scanner drivers that are installed, and the ability to add new scanner drivers to their installed set after the application has been installed. The PixTools/Scan toolkit has some built-in features which make this a relatively easy problem to solve.

Selecting and installing drivers is different depending on which platform you are working with; therefore, this section is divided into sections for each platform.

Selecting a Scanner

Under Microsoft Windows, scanner drivers may be located in the application directory, a directory of the application's choosing, or in the PIXTRAN subdirectory of the user's WINDOWS directory. Since early 1994, the PixTools Toolkit has been strongly recommending that application developers design their applications to load scanner drivers from the <WINDIR>\PIXTRAN directory. Following this recommendation will reduce problems associated with multiple applications loading multiple instances of the same driver, ensuring that each instance gets the correct version or a warning stating that the version currently loaded may not work properly with the newly-launched application.

Drivers have an extension of .PXN (some older drivers have an extension of .PXW . These will still work in some legacy Windows operating systems). The currently-selected driver, if any, is saved in the SETSCAN.INI file located in the user's WINDOWS directory under the section [Scanner]. Following is a portion of a typical SETSCAN.INI file:

 
Copy Code
[Scanner]
Driver=AGFAASPI

This shows that the currently-selected scanner is one that uses the AGFAASPI.PXW driver (for the Agfa StudioScan color scanner).

To allow the user to select from among the scanners whose drivers are installed, your application can call the following function from, for example, a Select Scanner command on the File menu:

 
Copy Code
IG_ISIS_drv_set_scan_name(HWND hParent);

with a parameter of the handle to the parent window. This results in a dialog box being displayed:

The list of scanners that appears in this dialog box differs according to the actual drivers on the user's disk. The user now picks the desired scanner from the list, then clicks OK. The following actions then occur:

  1. The library checks the SETSCAN.INI file to determine whether setup configuration information has ever been saved for the selected scanner. Every scanner ever selected has its own section in this file. If the driver has been selected in the past, then the scanner is selected using the previously-saved configuration information. If not, and if the scanner is one that has user-settable configuration information, the library displays the Scanner Configuration dialog box that would have been displayed if the user had clicked Setup instead of OK.
  2. To obtain this information, the library temporarily loads the scanner driver. When it does so, it checks permissions. If the user does not have sufficient permissions to use this driver, then an error message is displayed instead.
  3. Note that the Scanner Configuration dialog box can also be displayed independently by calling IG_ISIS_drv_configure. Many application developers choose to implement their own scanner selection dialog to conform to their application's look and style. If this is done, the scanner selection dialog should implement a Configure button which calls IG_ISIS_drv_configure() to allow the scanner to be configured. Once scanner configuration information has been established and written to the SETSCAN.INI file, the scanner is selected, and its driver is unloaded. The driver can now be used loaded and used by the application. (The driver does not remain loaded because, since your application did not load it, it does not have a handle to the driver and cannot reference it.)

Determining the Selected Scanner

So far, the application has displayed a dialog box asking the user to select a scanner, the user has selected a scanner, and configuration information for that scanner, if any, has been established. In order for the application to determine which scanner has been selected, it can call IG_ISIS_drv_get_scan_name(), which will return the name of the driver for the selected scanner. With this information, the application can load, initialize, and link the scanner driver into an ISIS pipe.

Adding a Scanner Driver

To add a scanner driver, the application can display the Scanner Selection dialog box by calling IG_ISIS_drv_set_scan_name(). The user can then click the Add button to display the Add Scanner dialog

This dialog prompts the user to insert a diskette containing the scanner driver, and then prompts the user through the installation process.

Keep in mind that the user can install any ISIS scanner driver, but may not have the necessary level of permissions to use it. In this case, the user will get an error message when the application loads the driver (probably when configuration is performed right after selecting the driver for the first time).

By using this dialog box, all drivers are installed in the <WINDIR>\PIXTRAN directory. If your application does not follow Pixel's guidelines for driver location, this may cause problems in your application's ability to load drivers.

Installing a Scanner Driver

Scanner drivers can be installed using the IG_ISIS_install_driver() function.If you want more control over the scanner driver installation process, use the IG_ISIS_install_driver_init() function (to return a IG_ISIS_install_driver handle) along with the IG_ISIS_install_driver_step() function (to perform each step in the installation) and IG_ISIS_install_driver_done() function (to clean up the installation). You can also call IG_ISIS_install_driver_set_long() and IG_ISIS_install_driver_set_ascii() to set up parameters of the installation.

See the online help for more information about these functions and specific tags.