Article ID: 308669 - View products that this article applies to.
This article was previously published under Q308669
You can use the Rescan sample program, which is available through this article, to enumerate all available SCSI adapters on the system and initiate bus rescan. This will find new devices that have been added to the bus since the previous bus scan.
The sample also obtains a handle to the device to send IOCTL commands to get the adapter properties. The sample also demonstrates enumeration of child devices through two different techniques. The first technique gets the inquiry data for each SCSI adapter, and the second technique uses the CM_xxx APIs.
The following file is available for download from the Microsoft Download Center:
Rescan1.exeRelease Date: OCT-17-2001
For more information about how to download Microsoft Support files, click the following article number to view the article in the Microsoft Knowledge Base:
119591Microsoft scanned this file for viruses. Microsoft used the most current virus-detection software that was available on the date that the file was posted. The file is stored on security-enhanced servers that help prevent any unauthorized changes to the file. The Rescan1.exe file contains the following files:
(https://support.microsoft.com/kb/119591/ )How to obtain Microsoft support files from online services
File Description --------------------------------------------------------------------- Rescan Implements the Win32 application to enumerate devices Rescan.h Header file for rescan.c Sources DDK build instructions Makefile Standard Windows 2000 makefile Rescan.txt The documentation for these samples (this article) Rescan.exe Windows 2000 executable program (free build)
Device enumerationThis sample uses the Setup class GUID GUID_DEVCLASS_SCSIADAPTER to enumerate all the SCSI adapters that are installed on the system. The sample gets the registry properties to obtain the device properties. It then initiates bus rescan and gets child device properties.
In order for a Win32 application to send IOCTLs, the application should have the handle to the device. To obtain the device handle, the application can use the device interface name to open the device. The SCSI port driver exposes this interface by registering the device interface. It uses the StoragePortClassGuid interface GUID for device registration. A Win32 application can use the SetupDi APIs with the same interface GUID to obtain this interface name. If this is done in a loop, all the registered SCSI adapter interfaces can be obtained. Because the SCSI port driver provides these values, this will work for all types of adapters that the SCSI port driver manages.
Adapter propertiesYou can use the IOCTL_STORAGE_QUERY_PROPERTY to get the adapter properties. This IOCTL takes the data structure STORAGE_PROPERTY_QUERY as an argument. Before you call this IOCTL, you must set the STORAGE_PROPERTY_ID and STORAGE_QUERY_TYPE member. You can set the STORAGE_PROPERTY_ID to either StorageAdapterProperty or StorageDeviceProperty. StorageAdapterProperty returns the properties of the adapters and StorageDeviceProperty returns the properties of the devices. This data structure and its member values are defined in \NTddk\Src\NTddstor.h.
This sample uses StorageAdapterProperty to obtain the adapter properties. This returns the STORAGE_ADAPTER_DESCRIPTOR data structure that contains adapter properties, such as the bus type, maximum transfer length, and alignment mask.
Child device propertiesThis sample uses the IOCTL_SCSI_GET_INQUIRY_DATA IOCTL to get the inquiry data from each bus. It then lists all devices with the SCSI address and device type.
The second technique that the sample demonstrates uses the CM_xxx APIs to get all the child devices of an adapter. It also gets the device instance ID for each child device.
Building the sample
Running the Rescan.exe sampleThis sample does not take any arguments, so simply execute it from a command prompt window. It will list each SCSI adapter and its child devices' properties.
For more information about Microsoft Windows Driver Development Kits, visit the following Microsoft Web page:
Article ID: 308669 - Last Review: November 23, 2005 - Revision: 3.1