Click here to Skip to main content
15,885,216 members
Articles / Desktop Programming / MFC

Scan2PDF

Rate me:
Please Sign up or sign in to vote.
4.90/5 (75 votes)
22 Apr 20053 min read 432.9K   20.9K   230  
A utility for bulk scanning, converting the scanned pages to PDF and burning them on CD/DVD for archiving.
/******************************************************************************
|* 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-2004 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.

CExitCode 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.

	m_NeroCDInfo = NeroGetCDInfo (m_NeroDeviceHandle, NGCDI_READ_CD_TEXT|NGCDI_READ_ISRC);
	if (NULL == m_NeroCDInfo)
	{
		return EXITCODE_ERROR_GETTING_CD_INFO;
	}

	return DisplayCDInfo ();
}

CExitCode CBurnContext::DisplayCDInfo (void)
{
	// Ask the NeroAPI to give the description of the media type and
	// print if the string exists.
	// 
	char * psMedia = NeroGetTypeNameOfMedia (m_NeroCDInfo->ncdiMediaType, NULL);
	if (psMedia != NULL && psMedia[0] != '\0')
	{
		printf ("%s", psMedia);
		NeroFreeMem (psMedia);
	}
	else
	{
		printf ("<no media>");
	}

	// 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");

	if (m_NeroCDInfo->ncdiAvailableEraseModes != 0)
	{
		printf ("Erase modes:");
		if (NCDI_IS_ERASE_MODE_AVAILABLE ((*m_NeroCDInfo), NEROAPI_ERASE_ENTIRE))
		{
			printf (" Entire");
		}
		if (NCDI_IS_ERASE_MODE_AVAILABLE ((*m_NeroCDInfo), NEROAPI_ERASE_QUICK))
		{
			printf (" Quick");
		}
		printf ("\n");
	}

	if (m_NeroCDInfo->ncdiMediumFlags != 0)
	{
		printf ("Medium flags:");
		
		if (0 != (m_NeroCDInfo->ncdiMediumFlags & NCDIMF_VIRTUALMULTISESSION))
		{
			printf (" VMS");
		}
		if (0 != (m_NeroCDInfo->ncdiMediumFlags & NCDIMF_HDB_SUPPORTED))
		{
			printf (" HDB");
		}
		
		printf ("\n");
	}

	printf ("Layer 0 max blocks: %d\n", m_NeroCDInfo->ncdiLayer0MaxBlocks);
	printf ("Total capacity: %d\n", m_NeroCDInfo->ncdiTotalCapacity);
	
	printf ("\n");

	// Print out information regarding each and every track..

	for (DWORD i = 0; i < m_NeroCDInfo->ncdiNumTracks; i++)
	{
		if (i == 0)
		{
			printf ("  %3s %-6s %-10s %-10s %-10s %-5s %s\n",
				"###",
				"Type",
				"Start",
				"Stop",
				"Length",
				"Sess#",
				"ISRC");
			printf ("  ---+------+----------+----------+----------+-----+----\n");
		}

		NERO_TRACK_INFO * pTrackInfo = &m_NeroCDInfo->ncdiTrackInfos[i];

		printf ("  %02d. %-6s 0x%08x 0x%08x 0x%08x %5d %-15.15s\n",
				pTrackInfo->ntiTrackNumber,
				pTrackInfo->ntiTrackType == NTT_AUDIO ? "audio" : pTrackInfo->ntiTrackType == NTT_DATA ? "data" : "unknown",
				pTrackInfo->ntiTrackStartBlk,
				pTrackInfo->ntiTrackStartBlk + pTrackInfo->ntiTrackLengthInBlks - 1,
				pTrackInfo->ntiTrackLengthInBlks,
				pTrackInfo->ntiSessionNumber,
				pTrackInfo->ntiISRC);
		
		if (pTrackInfo->ntiArtist[0] != '\0')
		{
			printf ("      Artist: \"%s\"\n", pTrackInfo->ntiArtist);
		}
		if (pTrackInfo->ntiTitle[0] != '\0')
		{
			printf ("      Title: \"%s\"\n", pTrackInfo->ntiTitle);
		}
	}
	
	// If virtual multisession is supported...
	// 
	if (0 != (m_NeroCDInfo->ncdiMediumFlags & NCDIMF_VIRTUALMULTISESSION))
	{
		NERO_VMS_INFO * pVMSInfo = NeroGetVMSInfo (m_NeroDeviceHandle, 0);
		
		if (pVMSInfo != NULL)
		{
			printf ("\nVirtual multisession info:\n");
			printf ("Next writable address: 0x%08x\n", pVMSInfo->nvmsiNextWritableAddress);
			
			printf ("\n");

			for (DWORD i = 0; i < pVMSInfo->nvmsiNumSessions; i++)
			{
				if (i == 0)
				{
					printf ("  %3s %-20s %-10s %s\n",
						"###",
						"Session name",
						"Next addr",
						"Creation time");
					printf ("  ---+--------------------+----------+-------------\n");
				}

				const NERO_VMSSESSION & VMSSession = pVMSInfo->nvmsiSessionInfo[i];
				
				printf ("  %02d. %-20.20s 0x%08x %s",
					i + 1,
					VMSSession.nvmssSessionName,
					VMSSession.nvmssNextWritableAddress,
					asctime (&VMSSession.nvmssCreationTime));
			}

			NeroFreeMem (pVMSInfo);
		}
	}

	return EXITCODE_OK;
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
CEO Solaris Electronics LLC
United Arab Emirates United Arab Emirates
I was born in Shiraz, a very beautiful famous city in Iran. I started programming when I was 12 years old with GWBASIC. Since now, I worked with various programming languages from Basic, Foxpro, C/C++, Visual Basic, Pascal to MATLAB and now Visual C++.
I graduated from Iran University of Science & Technology in Communication Eng., and now work as a system programmer for a telecommunication industry.
I wrote several programs and drivers for Synthesizers, Power Amplifiers, GPIB, GPS devices, Radio cards, Data Acquisition cards and so many related devices.
I'm author of several books like Learning C (primary and advanced), Learning Visual Basic, API application for VB, Teach Yourself Object Oriented Programming (OOP) and etc.
I'm winner of January, May, August 2003 and April 2005 best article of month competition, my articles are:


You can see list of my articles, by clicking here


Comments and Discussions