www.pudn.com > NEROSDK5582.ZIP > CommandCDInfo.cpp
/******************************************************************************
|* THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
|* ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
|* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
|* PARTICULAR PURPOSE.
|*
|* Copyright 1995-2002 Ahead Software AG. All Rights Reserved.
|*-----------------------------------------------------------------------------
|* NeroSDK / NeroCmd
|*
|* PROGRAM: CommandCDInfo.cpp
|*
|* PURPOSE: Retrieve CD information
******************************************************************************/
#include "stdafx.h"
#include "BurnContext.h"
// This function performs execution of a CD info command.
EXITCODE CBurnContext::CommandCDInfo (const PARAMETERS & params)
{
// Retrieve a pointer to a NERO_CD_INFO structure for the specified device.
// NULL will be returned if an error occurred.
// The allocated memory for the structure has to be freed by using NeroFreeMem().
// This will be performed by the destructor of CBurnContext.
// NGCDI_READ_CD_TEXT is the only constant allowed.
m_NeroCDInfo = NeroGetCDInfo (m_NeroDeviceHandle, NGCDI_READ_CD_TEXT);
if (NULL == m_NeroCDInfo)
{
GetLastErrorLogLine();
return EXITCODE_ERROR_GETTING_CD_INFO;
}
// Print medium type.
switch (m_NeroCDInfo->ncdiMediumType)
{
case NMT_CD_ROM:
printf ("CD-ROM");
break;
case NMT_CD_RECORDABLE:
printf ("CD-R");
break;
case NMT_CD_REWRITEABLE:
printf ("CD-RW");
break;
default:
printf ("unknown disc");
break;
}
// Print other CD information.
printf (", %s, %d blocks free\n"
"Artist %s, Title %s\n",
m_NeroCDInfo->ncdiIsWriteable ? "writeable" : "not writable",
m_NeroCDInfo->ncdiFreeCapacityInBlocks,
m_NeroCDInfo->ncdiArtist[0] ? m_NeroCDInfo->ncdiArtist : "unknown",
m_NeroCDInfo->ncdiTitle[0] ? m_NeroCDInfo->ncdiTitle : "unknown");
// Print out information regarding each and every track..
for (int i = 0; i < (int)(m_NeroCDInfo->ncdiNumTracks); i++)
{
NERO_TRACK_INFO * pTrackInfo = &m_NeroCDInfo->ncdiTrackInfos[i];
printf ("%02d. %6s %6d - %6d = %6d blocks, session %d",
pTrackInfo->ntiTrackNumber,
pTrackInfo->ntiTrackType == NTT_AUDIO ? "audio" : pTrackInfo->ntiTrackType == NTT_DATA ? "data" : "unknown",
pTrackInfo->ntiTrackStartBlk,
pTrackInfo->ntiTrackStartBlk + pTrackInfo->ntiTrackLengthInBlks,
pTrackInfo->ntiTrackLengthInBlks,
pTrackInfo->ntiSessionNumber);
if (pTrackInfo->ntiArtist[0] || pTrackInfo->ntiTitle[0])
{
printf (" (%s %s)\n", pTrackInfo->ntiArtist, pTrackInfo->ntiTitle);
}
else
{
printf ("\n");
}
}
return EXITCODE_OK;
}