Documentation for NeroCom

vbimport

#1

hi everybody

i try to use NeroCom.dll in my c# project to burn data. i try to find any documentation about objects in NeroCom.dll but i can’t find any.

can anyone send me information about how can i get that documentation?

i found a code that doing it but i don't think i understand it so much:

using System;
using System.IO;
using System.Collections;
using System.Threading;
using System.Drawing;
using System.Windows.Forms;
using NEROLib;

namespace CDServices_NET
{
    public delegate void OnProgressDelegate (int ProgressInPercent, string phase);
    
    public class CDService: System.Windows.Forms.Form
    {
        #region Attributes
        private NeroClass nClass;
        private NeroFolder nRootFolder;
        private NeroDrive nDrive;
        private NeroDrives nDrives;
        private NeroISOTrack nISOTrack;
        private string artist = "";
        private string title = "";
        private string imageTarget = @"c:image.iso";
        private NERO_MEDIA_TYPE nType = 0;
        private int burningSpeed;
        private bool longOperation = false;
        private string phase = "";
        private ProgressForm myProgressForm = new ProgressForm();
        # endregion

        #region Events
        public event OnProgressDelegate OnNeroProgress;
        #endregion
        
        # region Properties
        public string Artist 
        {
            get 
            {
                return artist;
            }
            set 
            {
                artist = value;
            }
        }

        public string Title 
        {
            get 
            {
                return title;
            }
            set 
            {
                title = value;
            }
        }

        public string ImageTarget 
        {
            get 
            {
                return imageTarget;
            }
            set 
            {
                imageTarget = @value;
            }
        }
        # endregion

        #region Contructors
        public CDService()
        {
            nClass = new NeroClass();
            nRootFolder = new NeroFolderClass();
            nISOTrack = new NeroISOTrackClass();            
        }
        #endregion
        
        # region static Methods
        public static void StaticBurn( string title, string imageTarget, string path, string recorder, int burningSpeed, string mediaType)
        {
            NERO_MEDIA_TYPE nType = (NERO_MEDIA_TYPE) Enum.Parse(typeof(NERO_MEDIA_TYPE), mediaType, true);
            CDService cd = new CDService();
            cd.SelectRecoder(recorder);    
            cd.ImageTarget = imageTarget;
            cd.Title = title;
            cd.AddAllToFolderRecursive(new DirectoryInfo(@path));        
            cd.nISOTrack.Name = cd.Title;
            cd.Burn(burningSpeed, nType);
        }

        public static void StaticBurn( string title, string path, string recorder, int burningSpeed, string mediaType)
        {
            StaticBurn (title, @"c:image.iso", path, recorder, burningSpeed, mediaType);            
        }
        # endregion

        #region Methods        
        
        public void Burn ( string title, string imageTarget, string path, string recorder, int burningSpeed, string mediaType)
        {
            Title = title;
            ImageTarget = imageTarget;
            AddAllToFolderRecursive(new DirectoryInfo(@path));    
            SelectRecoder(recorder);
            Burn(burningSpeed);
        }

        public void Burn(int burningSpeed)
        {
            Burn(burningSpeed, NERO_MEDIA_TYPE.NERO_MEDIA_NONE);
        }

        public void Burn(int speed, NERO_MEDIA_TYPE mediaType)
        {        
            if (nDrive == null)
                throw new Exception("no recorder selected");
            myProgressForm.totalNumber = 100;
            myProgressForm.Show();
            nISOTrack.RootFolder = nRootFolder;
            burningSpeed = speed;
            nType = mediaType;
            
            
            longOperation = true;
            nDrive.EstimateTrackSize(nISOTrack, NERO_ESTIMATE_FLAGS.NETS_DATA, null);
            
            
            //adding handler    
            nDrive.OnDoneBurn += new _INeroDriveEvents_OnDoneBurnEventHandler(OnDoneBurn);
            nDrive.OnProgress += new _INeroDriveEvents_OnProgressEventHandler(OnProgress);
            nDrive.OnDoneWaitForMedia += new _INeroDriveEvents_OnDoneWaitForMediaEventHandler(nDrive_OnDoneWaitForMedia);
            nDrive.OnAddLogLine += new _INeroDriveEvents_OnAddLogLineEventHandler(nDrive_OnAddLogLine);
            nDrive.OnSetPhase += new _INeroDriveEvents_OnSetPhaseEventHandler(nDrive_OnSetPhase);
            nDrive.OnAborted += new _INeroDriveEvents_OnAbortedEventHandler(nDrive_OnAborted);
            nDrive.OnDoneCDInfo +=new _INeroDriveEvents_OnDoneCDInfoEventHandler(nDrive_OnDoneCDInfo);
            nDrive.OnDoneEstimateTrackSize +=new _INeroDriveEvents_OnDoneEstimateTrackSizeEventHandler(nDrive_OnDoneEstimateTrackSize);
            nDrive.OnDoneImport += new _INeroDriveEvents_OnDoneImportEventHandler(nDrive_OnDoneImport);
            
            nClass.OnFileSelImage += new _INeroEvents_OnFileSelImageEventHandler(OnFileSelImage);
            nClass.OnMegaFatal += new _INeroEvents_OnMegaFatalEventHandler(nClass_OnMegaFatal);
            nClass.OnNonEmptyCDRW += new _INeroEvents_OnNonEmptyCDRWEventHandler(nClass_OnNonEmptyCDRW);
            nClass.OnWaitCD += new _INeroEvents_OnWaitCDEventHandler(nClass_OnWaitCD);
            nClass.OnWaitCDMediaInfo += new _INeroEvents_OnWaitCDMediaInfoEventHandler(nClass_OnWaitCDMediaInfo);
            nClass.OnWaitCDReminder += new _INeroEvents_OnWaitCDReminderEventHandler(nClass_OnWaitCDReminder);
            nClass.OnWaitCDDone += new _INeroEvents_OnWaitCDDoneEventHandler(nClass_OnWaitCDDone);
            nClass.OnDriveStatusChanged +=new _INeroEvents_OnDriveStatusChangedEventHandler(nClass_OnDriveStatusChanged);
            
            
            while(longOperation == true)
            {
                Thread.Sleep(500);
                Console.WriteLine("locked");
            }
            longOperation = true;                                            
            
            nDrive.BurnIsoAudioCD(Artist, Title, false, nISOTrack, null, null, NERO_BURN_FLAGS.NERO_BURN_FLAG_WRITE, 
                burningSpeed, nType); 

            while(longOperation == true)
            {
                Thread.Sleep(500);
                Console.WriteLine("locked");
            }
            
        
        }

        private ArrayList GetRecoderList(NERO_MEDIA_TYPE property)
        {
            nType = property;
            ArrayList al = new ArrayList();
            
            nDrives = (NeroDrives)nClass.GetDrives(property);
            
            foreach(NeroDrive nd in nDrives)
            {                
                al.Add(nd.DeviceName);                
            }
            return al;
        }

        public void SelectRecoder(string recoderName)
        {
            nDrives = (NeroDrivesClass)nClass.GetDrives(nType);                    
            foreach(NeroDrive nd in nDrives)
            {                
                if (nd.DeviceName == recoderName)
                {
                    nDrive = nd;
                    return;
                }
            }
            
            throw new Exception("cannot find selected target with Name: " + recoderName);
        }

        public void SelectRecoder(int  recoderID)
        {
            foreach(NeroDrive nd in nDrives)
            {                
                if (nd.DeviceID == recoderID)
                {
                    nDrive = nd;
                    return;
                }
            }
            throw new Exception("cannot find selected target with ID: " + recoderID);
        }

        public void AddAllToFolderRecursive(DirectoryInfo rootDir)
        {
            AddAllToFolderRecursive(nRootFolder, rootDir);
        }

        private void AddAllToFolderRecursive( NeroFolder rootFolder, DirectoryInfo rootDir)
        {
            foreach (FileInfo fi in rootDir.GetFiles())
            {
                NeroFile newFile = new NeroFileClass();
                newFile.Name = fi.Name;
                newFile.SourceFilePath = fi.FullName;
                rootFolder.Files.Add(newFile);
            }
            foreach (DirectoryInfo di in rootDir.GetDirectories())
            {
                NeroFolder newFolder = new NeroFolderClass();
                newFolder.Name = di.Name;
                rootFolder.Folders.Add(newFolder); 
                AddAllToFolderRecursive(newFolder, di);
            }
                
        }    
        
        
        //Here we present the user with the results of the burn process
        private void OnDoneBurn(ref NERO_BURN_ERROR statusCode)
        {
            longOperation = false;
            if (statusCode != NERO_BURN_ERROR.NERO_BURN_OK)
                Console.WriteLine("OnDoneBurn: NOT successful! " + statusCode + " " + nClass.ErrorLog.ToString() + nClass.LastError.ToString());            
            else
                Console.WriteLine("OnDoneBurn: successful! " + statusCode);
        
        }

        //Here we just want to display the text that NeroCOM offers us whenever a line is
        //added to the log.
        private void nDrive_OnAddLogLine(ref NERO_TEXT_TYPE TextType, ref string Text)
        {
            Console.WriteLine("nDrive_OnAddLogLine: " + TextType + " : " + Text);
        }

        //OnAborted queries whether an operation shall be aborted. We always return
        //false; if we choose to abort, we will explicitly call the Nero object’s abort method.
        private void nDrive_OnAborted(ref bool Abort)
        {
            Abort = false;            
        }

        //progress reports from NeroCOM.
        private void OnProgress(ref int ProgressInPercent, ref bool Abort)
        {
            Abort = false;
            if (OnNeroProgress != null)
                OnNeroProgress(ProgressInPercent, this.phase);

            Console.WriteLine("OnProgress: " + ProgressInPercent);
            myProgressForm.currentNumber = ProgressInPercent;
            //myProgressForm.Invalidate();
        }
        
        //This event will be called when Nero has stopped waiting for the media.
        private void nDrive_OnDoneWaitForMedia(ref bool Success)
        {            
            Console.WriteLine("nDrive_OnDoneWaitForMedia: ");
        }

        //finding out about the current phase NeroCOM is in –
        //writing data, writing lead-in or lead-out parts of the CD-ROM and related information.
        private void nDrive_OnSetPhase(ref string Text)
        {
            this.phase = Text;
            Console.WriteLine("nDrive_OnSetPhase: " + Text);
        }
    

        //This handler is called when a very critical error occurs.
        private void nClass_OnMegaFatal()
        {
            Console.WriteLine("nClass_OnMegaFatal: " + "A mega fatal error has occurred.");
        }

        //If the user decides to use the virtual device and not a real device more
        //information is needed. The data that NeroCOM creates will be written to an
        //image file. To provide the location of that file we need to handle this event.
        private void OnFileSelImage(ref string target)
        {            
            target = ImageTarget;    
            Console.WriteLine("OnFileSelImage: " + target);
        }

        //This event will be called whenever the user tries to write on a non-empty CD-RW.
        //We merely return NERO_RETURN_EXIT, although of course more sophisticated
        //ways of handling this message are possible, e.g. by asking the user if he wants to
        //erase the CD-RW.
        private void nClass_OnNonEmptyCDRW(ref NERO_RESPONSE Response)
        {
            Response = NERO_RESPONSE.NERO_RETURN_EXIT;
            Console.WriteLine("nClass_OnNonEmptyCDRW: NERO_RETURN_EXIT");
        }

        //This event will be called when Nero is waiting for a CD to be inserted into the
        //drive.
        private void nClass_OnWaitCD(ref NERO_WAITCD_TYPE WaitCD, ref string WaitCDLocalizedText)
        {
            Console.WriteLine("nClass_OnWaitCD: " + WaitCDLocalizedText);
        }

        //This event will be fired when Nero is waiting for a particular type of media.
        private void nClass_OnWaitCDMediaInfo(ref NERO_MEDIA_TYPE LastDetectedMedia, ref string LastDetectedMediaName, ref NERO_MEDIA_TYPE RequestedMedia, ref string RequestedMediaName)
        {
            Console.WriteLine("nClass_OnWaitCDMediaInfo: Waiting for a particular media type: " + RequestedMediaName);
        }

        //This event will occur when Nero has been waiting for the insertion of a CD for
        //quite a while.
        private void nClass_OnWaitCDReminder()
        {
            Console.WriteLine("nClass_OnWaitCDReminder: Waiting for CD");
        }
        #endregion

        private void nDrive_OnDoneCDInfo(INeroCDInfo pCDInfo)
        {
            Console.WriteLine("nDrive_OnDoneCDInfo: " + pCDInfo.ToString());
        }

        private void nDrive_OnDoneEstimateTrackSize(bool bOk, int BlockSize)
        {
            longOperation = false;    
            Console.WriteLine("nDrive_OnDoneEstimateTrackSize: " + bOk + "Blocksize: " + BlockSize);
                
        }

        private void nDrive_OnDoneImport(ref bool Ok, ref NeroFolder Folder, ref NeroCDStamp CDStamp)
        {
            Console.WriteLine("nDrive_OnDoneImport: " + Ok + Folder.ToString() + CDStamp);
        }

        private void nClass_OnWaitCDDone()
        {
            Console.WriteLine("nClass_OnWaitCDDone");
        }

        private void nClass_OnDriveStatusChanged(int hostID, int targetID, NERO_DRIVECHANGE_RESULT driveStatus)
        {
            Console.WriteLine("nClass_OnDriveStatusChanged: hostID:" + hostID + " targetID:" + targetID + " " + driveStatus);
        }
    }

}

#2

You need to download the sdk files from the ahead website: