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.
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:
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.
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.
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.