This sample is a working example of an STI (Still Image) user-mode minidriver. The main purpose of this sample is to show how to implement events in the minidriver. Events are hardware-initiated, usually caused when the user pushes a button on the device. Rather than require the installation of hardware, this sample uses a test file to simulate hardware events. When the test file changes or changes size, the minidriver simulates a hardware event.
This user-mode minidriver sample works in conjunction with a sample control panel found in the Sampcpl directory. Both parts need to be built to run this example.
To build the sample, open a DDK command window, change to the Sampusd directory, and use the build command. After building, put the Sampusd.dll and Sampusd.inf files in a temporary directory with the Sampcpl.cpl file built from the Sampcpl directory of the DDK. To install it, use the Hardware Wizard control panel, or the Add button in the Scanners and Cameras control panel. When prompted by the wizard to search for your new hardware, select No, and then select Imaging Device from the next dialog box.
Use the Have Disk button to point to the temporary directory where the files are located. The wizard will ask if the device is attached to COM1 or COM2. It doesn't matter which one you choose, as this value will be changed later. In the Scanners and Cameras control panel, select Properties of the sample device. It will initially read, "Status: Unavailable." On the Sample USD tab, type in the name of a temporary test file (for example, C:\Temp\Sample.txt). Create the test file if it does not already exist. The value will not be updated in the control panel until the Still Image Service is restarted. Open the Computer Manager (right-click My Computer and select Manage), select System Tools, and then Services, and stop and then restart the Still Image service.
To simulate an event, use the test file created above. Changing the test file's size will cause a File Size Changed event. Altering the file without changing its size will cause a File Time Changed event. These events can be linked to different applications using the Event tab in the Scanners and Cameras control panel. Try causing each of these events and watch the applications launch.
This sample has not been tested on Alpha platforms. It has not been confirmed to be 64-bit compliant. The code builds properly with Microsoft Visual C® 6.0. Plug and Play and Power Management are not applicable to this sample.
Building this sample produces three files: Sampusd.dll, Sampusd.lib, and Sampusd.exp. Both free and checked versions are buildable. The sample has been tested with a binary that was built with Visual C 5.0.
The minidriver is used by two software components: the Scanners and Cameras control panel and the Still Image service. The Control Panel uses the minidriver to check on the status of the device. The Still Image service will check if the device has an event pending.
By building and using a checked (debug) version of the minidriver and a debugger, you can examine how it works in each of these instances. To debug the minidriver when it is called by the Control Panel, use control sticpl.cpl as the command for the debugger to execute. Put a breakpoint in one or more of the functions in Device.cpp that the control panel calls (e.g. GetStatus, Diagnostic, Initialize, LockDevice, UnLockDevice). To debug the minidriver when it is called by the Still Image service, use stisvc.exe -a as the command and put a breakpoint in GetStatus, Initialize, DeviceReset, LockDevice, or UnLockDevice. Since this sample also support events, the GetNotificationData function will also be of interest.
The Stillvue application in the Scancam\App directory of this DDK can be used to test any function in the minidriver. See the documentation in that directory for more information.
More information on TWAIN can be found at http://www.twain.org.
To get a logo for your device, consult WHQL for information and test suites.
Your device should support Plug and Play, even if it uses the parallel or serial port. Download Plug and Play specs from their Web site.
File DescriptionSampusd.htm The documentation for this sample (this file) Sampusd.cpp Implements DLL and COM housekeeping Device.cpp Implements the functions of the minidriver Sampusd.h Main header file Sampusd.rc Main resource file Sampusd.rcv Contains version resource Resource.h Resource defines (currently empty) Makefile The makefile for the project; do not edit. Sources DDK build instructions Sampusd.def DLL definition Sampusd.inf Installation information for the sample
Each of the functions implemented in device.cpp is documented in the DDK documentation under Still Image Interfaces, IStiUSD Interface.
© 1999 Microsoft Corporation