Scanning the SCSI2 bus

Extra-simple C++ Builder project.
Use it even if a SCSI2 host adapter is not installed into your PC.
ATAPI devices will be listed as well !

Prerequisite

The only prerequisite is being in posses of the ASPIDLL.DLL described here.

Build the application in 4 easy steps:

  • create a new project with C++ Builder
  • declare the following items into the unit1 header:
    
    HINSTANCE AspiDllHandle;
    bool ( __stdcall *pfnFFAspiStart )( HWND );
    void ( __stdcall *pfnFFSCSIBusScan )( HWND );
    void ( __stdcall *pfnFFAspiStop )( void );
    
  • put a button on the form and assign its OnClick event to the following handler:
    
    void __fastcall TForm1::Button1Click(TObject *Sender)
    {
    // load ASPIDLL.DLL
       AspiDllHandle = LoadLibrary ( "ASPIDLL.DLL" );
       if ( AspiDllHandle == 0 )
          {
            MessageBox ( NULL, "LoadLibrary:\nASPIDLL.DLL not found.",
                               "Error FS 001", MB_SYSTEMMODAL );
            return;
          }
    
    // load FFAspiStart address
       pfnFFAspiStart = ( bool ( __stdcall *)( HWND ) )
          GetProcAddress ( AspiDllHandle, "FFAspiStart" );
       if ( pfnFFAspiStart == NULL )
          {
            MessageBox ( NULL, "GetProcAddress:\nFFAspiStart not found.",
                               "Error FS 002", MB_SYSTEMMODAL );
            return;
          }
    
    // load FFSCSIBusScan address
       pfnFFSCSIBusScan = ( void ( __stdcall *)( HWND ) )
          GetProcAddress ( AspiDllHandle, "FFSCSIBusScan" );
       if ( pfnFFSCSIBusScan == NULL )
          {
            MessageBox ( NULL, "GetProcAddress:\nFFSCSIBusScan not found.",
                               "Error FS 003", MB_SYSTEMMODAL );
            return;
          }
    
    // load FFAspiStop address
       pfnFFAspiStop = ( void ( __stdcall *)( void ) )
          GetProcAddress ( AspiDllHandle, "FFAspiStop" );
       if ( pfnFFAspiStop == NULL )
          {
            MessageBox ( NULL, "GetProcAddress:\nFFAspiStop not found.",
                               "Error FS 004", MB_SYSTEMMODAL );
            return;
          }
    
    // check ASPI support
       if ( pfnFFAspiStart ( Application -> Handle ) == false )
          {
            MessageBox ( NULL, "No ASPI support.",
                               "Error FS 005", MB_SYSTEMMODAL );
            return;
          }
    
    // start ASPI support
       pfnFFAspiStart ( Application -> Handle );
    
    // scan the SCSI2 bus
       pfnFFSCSIBusScan ( Application -> Handle );
    
    // stop ASPI support
       pfnFFAspiStop ( );
    
    // unload the DLL
       FreeLibrary ( AspiDllHandle );
    }
    
  • compile, click the button and... voila' !
That's all.