Sample Media Label Library

[This is preliminary documentation and subject to change.]

The following section contains the source code for an example media label library that identifies a fictitious media label. If you use industry-standard media formats, such as Microsoft tape format (MTF) and System Independent Data Format (SIDF), keep in mind that other companies use these formats. Your media label library should not recognize all MTF or SIDF media labels; it should recognize only those written by your application.

DWORD ClaimMediaLabel (const BYTE * const pBuffer, 
                 const DWORD nBufferSize,
                 MediaLabelInfo *pLabelInfo)
{
    #include <ntmsmli.h>
    // local variables
    NTMS_FictLabel   *pLabel ;
    // see if this is our format ...
    pLabel = (NTMS_FictLabel *) pBuffer ;
    // if this is the NTMS Fictitious Media Label ... get the 
    // appropriate info out of it ...
    if (wcsncmp (pLabel->LabelType, L"NTMS Fictitious Media 
             Label", NTMS_FictLabelTypeSize)  == 0)
    {
        // use Unicode string copy functions ... if the 
        // strings in the media label are not in Unicode then 
        // they must first be converted to Unicode by using 
        // mbstowcs() routine and then copied into the 
        // MediaLabelInfo structure ...
        wcscpy (pLabelInfo->LabelType, pLabel->LabelType)
        pLabelInfo->LabelIDSize = pLabel->LabelIDSize ;
        memcpy (pLabelInfo->LabelID, pLabel->LabelID, 
              pLabelInfo->LabelIDSize) ;
        wcscpy (pLabelInfo->LabelAppDescr, 
              pLabel->LabelAppDescr) ;
        return NO_ERROR ;
    }
    // not an NTMS fictitious media label ...
    return ERROR_BAD_FORMAT ;
}
DWORD MaxMediaLabel (DWORD * const pMaxSize)
{
    // set the max size for the NTMS fictitious media label ...
    *pMaxSize = 1024 ;
    return NO_ERROR ;
}