StarBurn SDK (Software Development Kit)
ContentsIndexHome
PreviousUpNext
StarBurn_FindDevice Function
C++
__stdcall STARBURN_IMPEX_API LONG StarBurn_FindDevice(IN UCHAR p__UCHAR__DeviceType, IN BOOLEAN p__BOOLEAN__IsFindFirst, IN PCALLBACK p__CALLBACK, IN PVOID p__PVOID__CallbackContext);
Parameters 
Description 
IN UCHAR p__UCHAR__DeviceType 
SCSI device type to find
 
IN BOOLEAN p__BOOLEAN__IsFindFirst 
TRUE if the function will return after locating first device, FALSE to process all the devices.
 
IN PVOID p__PVOID__CallbackContext 
Callback context that will be passed as second parameter into call to p__PCALLBACK. 
p__PCALLBACK 
Callback function that will be called with FIND_DEVICE CALLBACK_NUMBER, callback context and adapter ID and Target ID of the device.
 

Number of devices found. If zero - nothing was found.

This function finds device of the specified device type.

Please see the FindDevice sample that will demonstrate how to find CD/DVD/Blu-Ray/HD-DVD devices installed in the system.

This example finds first first CD/DVD/Blu-Ray/HD-DVD device, allocates CdvdBurnerGrabber object, and destroys the device object after it's not needed any more. 

 

VOID
__stdcall
Find_Callback(
    IN CALLBACK_NUMBER p__CALLBACK_NUMBER,
    IN PVOID p__PVOID__CallbackContext,
    IN PVOID p__PVOID__CallbackSpecial1,
    IN PVOID p__PVOID__CallbackSpecial2
    )
{

PVOID l__PVOID__CdvdBurnerGrabber;
EXCEPTION_NUMBER l__EXCEPTION_NUMBER;
ULONG l__ULONG__SystemError;
CHAR l__CHAR__ExceptionText[ 1024 ];
CDB_FAILURE_INFORMATION l__CDB_FAILURE_INFORMATION;

// Prepare exception text buffer
RtlZeroMemory(
    &l__CHAR__ExceptionText,
    sizeof( l__CHAR__ExceptionText )
    );

// Prepare CDB failure information
RtlZeroMemory(
    &l__CDB_FAILURE_INFORMATION,
    sizeof( l__CDB_FAILURE_INFORMATION )
    );

// Try to create CdvdBurnerGrabber on passed address (bus ID is always 0 in case of ASPI and LUN cannot be probed so 
// always 0 as well) with 32MB of cache)
l__EXCEPTION_NUMBER =
StarBurn_CdvdBurnerGrabber_Create(
    &l__PVOID__CdvdBurnerGrabber,
    ( PCHAR )( &l__CHAR__ExceptionText ),
    sizeof( l__CHAR__ExceptionText ),
    &l__ULONG__SystemError,
    &l__CDB_FAILURE_INFORMATION,
    ( PCALLBACK )( StarBurn_Callback ),
    ( UCHAR )( p__PVOID__CallbackSpecial1) ,
    0,
    ( UCHAR )( p__PVOID__CallbackSpecial2) ,
    0,
    32
    );

// Check for correct reply
if (  l__EXCEPTION_NUMBER != EN_SUCCESS )
{
// Handle error here...
}

// Do something with CdvdBurnerGrabber device object here...        

// Destroy the CdvdBurnerGrabber
StarBurn_Destroy( &l__PVOID__CdvdBurnerGrabber );

// Just check for pointer (paranoid?)
if ( l__PVOID__CdvdBurnerGrabber != NULL )
{
// Handle error here...
}

}

// Somewhere in the code

// Try to find device
if (
StarBurn_FindDevice(
    SCSI_DEVICE_RO_DIRECT_ACCESS,
    TRUE,
    ( PCALLBACK )( Find_Callback ),
    NULL
    ) == 0
)
{
// Handle error here...
}
else
{
// All actions are in the callback function...
}