Burn files to CD/DVD

Burn files to CD/DVD

Postby Natter » Tue Jul 05, 2016 8:37 pm

Hi !

Can I burn files to CD/DVD drive ?
Natter
 
Posts: 1216
Joined: Mon May 14, 2007 9:49 am

Re: Burn files to CD/DVD

Postby Silvio.Falconi » Wed Jul 06, 2016 8:00 am

Stephan Haupt Made something of it many years a go
Perhaps someone have this class because Stephan is dead
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7056
Joined: Thu Oct 18, 2012 7:17 pm

Re: Burn files to CD/DVD

Postby Silvio.Falconi » Wed Jul 06, 2016 8:11 am

I found a copy :

XPBurn
this use XPBurnObj.dll you can found here :https://bayden.com/Other/
Code: Select all  Expand view


//****
FUNCTION BurnCDInXP()
//****
LOCAL cBurnPath
//
IF ( oCD := XPBurnObj() ) != NIL )
   oFSO := CreateObject( "Scripting.FileSystemObject" ) // If we get here we're in XP and this shouldn't fail...
   //
   WITH OBJECT ( oCD )
      :ClearFiles()                                     // Erases ALL files from burning area...
      //
      MakeDir( cBurnPath := ( :BurnArea + "\Backup" ) ) // Build your directory structure...
      MakeDir( cBurnPath += "\companyname" )
      //
      :AddFile( "c:\yourfile.ext" )                     // This method add the file to the root of the CD..
      oFSO:CopyFile( "u:\yourfile.zip", cBurnPath + "\backup.ext" )
                                                        // Copy to the directory you just created...
      //
      :StartBurn()                                      // Invokes the XP Burning wizard...
   END
ENDIF
//
RETURN (.T.)

//***
FUNCTION XPBurnObj()
//***
   LOCAL oBurn
   //
   IF Os_IsWinXP()
      TRY
         oBurn := CreateObject( "BaydenBurn.XPBurn" )
         IF !( oBurn:Equipped )
            oBurn := NIL
         ENDIF
      CATCH
      END
   ENDIF
   //
   RETURN ( oBurn )



If you have application Nero you can use another this class but never I tried it

Code: Select all  Expand view
#include "hbclass.ch"
#include "classex.ch"

#define NERO_MEDIA_CD                     1
#define NERO_MEDIA_CDRW                 129
#define NERO_MEDIA_CDR                  257
#define NERO_MEDIA_DVD_ANY           262172

#define NERO_AUDIO_TRACK_FILE_MP3         2

#define NERO_BURN_OPTION_USE_JOLIET       1
#define NERO_BURN_OPTION_CREATE_ISO_FS    8

#define NERO_BURN_FLAG_SIMULATE           2
#define NERO_BURN_FLAG_WRITE              4

CLASS NeroBurnCD
//****
   CLASSDATA  nInstance INIT 0

   DATA oNero         INIT NIL
   DATA lNero         INIT .F.
   DATA oNeroDrives   INIT NIL
   DATA oNeroISOTrack INIT NIL
   DATA aDrives       INIT {}
   DATA oNeroBurn     INIT NIL
   DATA oNeroFolder   INIT NIL
   DATA nDriveActive  INIT 0
   DATA cType         INIT 0
   DATA aFiles        INIT {}
   DATA aNeroFiles    INIT {}

   DATA oLastError   INIT NIL
   DATA aErrors      INIT {}

   ACCESS lBurnersOK           INLINE ( LEN( ::aDrives ) > 0 )
   ACCESS lNeroOK              INLINE ( ::oLastError = NIL .AND. EMPTY(
::aErrors ) )

   ACCESS EnableOverBurn       INLINE IF( ::lNero, ::oNero:EnableOverBurn,
.F. )
   ASSIGN EnableOverBurn( l )  INLINE IF( ::lNero, ::oNero:EnableOverBurn :=
l, NIL )
   ACCESS DVDOverburnSize      INLINE IF( ::lNero, ::oNero:DVDOverburnSize,
0 )
   ASSIGN DVDOverburnSize( n ) INLINE IF( ::lNero, ::oNero:DVDOverburnSize
:= n, NIL )

   METHOD New()                                CONSTRUCTOR

   METHOD CreateAlbum()                        INLINE ::CreateNeroObj( "A" )
   METHOD AddMP3( cFileName, cArtist, cTitle ) INLINE ::AddNewFile( "A",
cFileName, cArtist, cTitle )

   METHOD CreateISOTrack( cTitle, rootFolder )
   METHOD SetCDLabel( cTitle )                 INLINE ::CreateISOTrack(
cTitle )
   METHOD SetRootFolder( rootFolder )          INLINE ::CreateISOTrack(,
rootFolder )
   METHOD CreateFolder()                       INLINE ::CreateNeroObj( "F" )
   METHOD AddFile( cFileName )                 INLINE ::AddNewFile( "F",
cFileName )

   METHOD BurnCD( nSpeed, cArtist, cTitle )
   METHOD GetFolder()                          INLINE ( ::oNeroFolder )
   METHOD NeroInstalled()                      INLINE ( ::lNero )
   METHOD GetDrives()
   METHOD GetErrors()                          INLINE ( ::aErrors )
   METHOD IsDeviceReady()                      INLINE IF( ::oNeroBurn = NIL,
.F., ::oNeroBurn:DeviceReady )
   METHOD SetDriveToBurn( nDrive )
   METHOD Destroy()

   HIDDEN:

   METHOD CreateNeroObj( cObj )
   METHOD AddNewFile( cObj, cFileName, cArtist, cTitle )

ENDCLASS

//****
METHOD New() CLASS NeroBurnCD
//****
   LOCAL i
   //
   ::lNero := .F.
   IF ( ++ ::nInstance > 1 )
      RETURN Self
   ENDIF
   TRY
      ::oNero := GetActiveObject( "Nero.Nero" )
   CATCH
      TRY
         ::oNero := TOleAuto():new( "Nero.Nero" )
      CATCH
         ::oNero := NIL
      END
   END
   IF ( ::lNero := ( ::oNero != NIL ) )
      ::EnableOverburn := .F.
      ::DVDOverburnSize := 0
   ENDIF
   //
RETURN Self

//****
METHOD GetDrives()
//****
   TRY
      ::oNeroDrives := ::oNero:GetDrives( NERO_MEDIA_CDRW +
NERO_MEDIA_DVD_ANY )
      FOR i := 0 TO ::oNeroDrives:Count - 1
         AADD( ::aDrives, ::oNeroDrives:Item( i ):DeviceName )
      NEXT
      ::nDriveActive := 0
   CATCH oError
      ::oLastError := oError
      AADD( ::aErrors, oError:Description + " (" + ::oNero:LastError + ")" )
   END
   //
RETURN Self

//****
METHOD SetDriveToBurn( nDrive )
//****
   TRY
      ::nDriveActive := nDrive - 1
      ::oNeroBurn := ::oNeroDrives:Item( ::nDriveActive )
      ALERT( ::oNeroBurn:DeviceName + " activado !!!" )
   CATCH oError
      ::oLastError := oError
      AADD( ::aErrors, oError:Description + " (" + ::oNero:LastError + ")" )
      ::nDriveActive := 0
      ::oNeroBurn := NIL
   END
   //
RETURN Self

//****
METHOD CreateNeroObj( cObj )
//****
   TRY
      SWITCH cObj
      CASE "F"
         ::oNeroFolder := TOleAuto():new( "Nero.NeroFolder" )
         EXIT
      CASE "A"
         ::oNeroFolder := TOleAuto():new( "Nero.NeroAudioTracks" )
         EXIT
      END
      ::cType := cObj
   CATCH oError
      ::oLastError := oError
      AADD( ::aErrors, oError:Description + " (" + ::oNero:LastError + ")" )
   END
   //
RETURN Self

//****
METHOD AddNewFile( cObj, cFileName, cArtist, cTitle )
//****
   LOCAL oFile
   //
   TRY
      IF ( ::oNeroFolder = NIL )
         ALERT( "Cree el 'RootFolder' antes de añadir archivos !!!" )
         BREAK
      ENDIF
      IF ( cFileName IN ::aFiles )
         BREAK
      ENDIF
      IF FILE( cFileName )
         SWITCH cObj
         CASE "F"
            oFile := TOleAuto():new( "Nero.NeroFile" )
            oFile:Name := SUBSTR( cFileName, RAT("\",cFileName)+1 )
            oFile:SourceFilePath := cFileName
            EXIT
         CASE "
A"
            oFile := TOleAuto():new( "
Nero.NeroAudioTrack" )
            oFile:Artist := IF( cArtist = NIL, "
", cArtist )
            oFile:Title := IF( cTitle = NIL, "
", cTitle )
            oFile:TrackType = NERO_AUDIO_TRACK_FILE_MP3
            oFile:FileName := cFileName
            EXIT
         END
         //
         AADD( ::aFiles, cFileName )
         AADD( ::aNeroFiles, oFile )
         SWITCH cObj
         CASE "
F"
            ::oNeroFolder:Files:Add( oFile )
            EXIT
         CASE "
F"
            ::oNeroFolder:Add( oFile )
            EXIT
         END
      ELSE
         ALERT( "
El archivo '" + cFileName + "' no existe !!!" )
      ENDIF
   CATCH oError
      ::oLastError := oError
      AADD( ::aErrors, oError:Description + "
(" + ::oNero:LastError + ")" )
   END
   //
RETURN Self

//****
METHOD CreateISOTrack( cTitle, rootFolder )
//****
   TRY
      IF ( ::oNeroISOTrack = NIL )
         ::oNeroISOTrack := TOleAuto():new( "
Nero.NeroISOTrack" )
         ::oNeroISOTrack:BurnOptions := ;
                    NERO_BURN_OPTION_CREATE_ISO_FS +
NERO_BURN_OPTION_USE_JOLIET
      ENDIF
      IF ( cTitle != NIL )
         ::oNeroISOTrack:name := cTitle
      ENDIF
      IF ( rootFolder != NIL )                   // Has to be a Nero.Folder
object...
         ::oNeroISOTrack:RootFolder := rootFolder
      ENDIF
   CATCH oError
      ::oLastError := oError
      AADD( ::aErrors, oError:Description + "
(" + ::oNero:LastError + ")" )
   END
   //
RETURN Self

//****
METHOD BurnCD( nSpeed, cArtist, cTitle )
//****
   TRY
     ::oNeroBurn:WaitForMedia( NERO_MEDIA_CD, ;
                          NERO_BURN_FLAG_SIMULATE + NERO_BURN_FLAG_WRITE,
NIL )
     ALERT( "
WaitForMedia" )
   END
   /*::oNeroBurn:UpdateDeviceInfo( NERO_MEDIA_CD )
   ALERT( ::oNeroBurn:DeviceName )
   ALERT( ::oNeroBurn:DeviceReady )
   ALERT( ::oNeroBurn:DriveLetter )
   ALERT( ::oNeroBurn:HostAdapterName ) */
   //IF ::IsDeviceReady()
      SWITCH ::cType
      CASE "
F"
         ::oNeroBurn:BurnIsoAudioCD( cArtist, cTitle, .F., ::oNeroISOTrack,
NIL, NIL, ;
                     NERO_BURN_FLAG_SIMULATE + NERO_BURN_FLAG_WRITE, nSpeed,
NERO_MEDIA_CD )
         EXIT
      CASE "
A"
         ::oNeroBurn:BurnIsoAudioCD( cArtist, cTitle, .F., NIL,
::oNeroFolder, NIL, ;
                   NERO_BURN_FLAG_SIMULATE + NERO_BURN_FLAG_WRITE, nSpeed,
NERO_MEDIA_CD )
         EXIT
      END
   //ELSE
   //   ALERT( "
Falta configurar algo o la unidad no esta lista !!!" )
   //ENDIF
   ::oNeroBurn:EjectCD()
   ::oNeroBurn:LoadCD()
   //
RETURN Self

//****
METHOD Destroy()
//****
   ::lNero         := .F.
   ::oNeroDrives   := NIL
   ::oNeroISOTrack := NIL
   ::aDrives       := {}
   ::oNeroBurn     := NIL
   ::oNeroFolder   := NIL
   ::aErrors   := {}
   ::oNero         := NIL
   //
RETURN Self
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7056
Joined: Thu Oct 18, 2012 7:17 pm

Re: Burn files to CD/DVD

Postby Silvio.Falconi » Wed Jul 06, 2016 8:17 am

Another test with Imapi
this first sample is working, but you have to install the Imapi2 support.
from MSDN:
Run-Time Requirements

IMAPI 2.0 is supported natively in Windows Vista and Windows Server 2008. Enabling IMAPI 2.0 functionality for Windows XP and Windows Server 2003 requires the installation of the KB932716 update package.

FUNCTION IMapi ()

LOCAL oMaster,oRecorder, nID, nIndex := 1, oDisc
// LOCAL cCLSID := "20CCA62-51A5-11D3-9144-00104BA11C5E"

// oMaster := CreateOleObject ("IMAPI.MsDiscMasterObj") // Imapi V1
// oDisc:= oMaster:IDiscMaster
// ? oDisc:Open()
oMaster := CreateObject("IMAPI2.MsftDiscMaster2")
oRecorder := CreateObject ("IMAPI2.MsftDiscRecorder2")
nID := oMaster:Item (nIndex)
oRecorder:InitializeDiscRecorder( nId )

? oRecorder:VolumeName

RETURN (nil)
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7056
Joined: Thu Oct 18, 2012 7:17 pm

Re: Burn files to CD/DVD

Postby Natter » Wed Jul 06, 2016 8:59 am

Silvio, thank you for your help !
Natter
 
Posts: 1216
Joined: Mon May 14, 2007 9:49 am

Re: Burn files to CD/DVD

Postby Silvio.Falconi » Fri Jul 08, 2016 6:53 am

I think the samples I publish are good only until windows xp professional but if someone have or found a solution for win7/8/10 can pubblish it here
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7056
Joined: Thu Oct 18, 2012 7:17 pm

Re: Burn files to CD/DVD

Postby ukoenig » Fri Jul 08, 2016 2:56 pm

Natter,
You can use

http://commandburner.com/

( very small : the exe is only 172 KB )
Includes everything You might need.
Just copy the files to Your progam-directory

includes :
CmdBurn.exe ( 172 KB )
CmdBurn.cmh ( 176 KB )
MCDB.ocx ( 370 KB )
Small.gif ( 2 KB )

CommandBurner is a free CD/DVD burning software utility that can be executed from the command line,
as well as through a simple interface.

CommandBurner can be executed from the command line, or through any method that passes command line arguments.
Simple options allow you to burn, erase, load and eject CDs and DVDs.

This makes CommandBurner suitable for integration with programs, scripts and batch files.
We imagine that CommandBurner would be useful for tasks such as scripting backups to CD/DVD,
but feel free to find other reasons to use it!

For added convenience, CommandBurner can also be opened in console mode, allowing the user
to perform the same CD/DVD burning operations using a simple point-and-click interface.

Media Support

CommandBurner supports ALL writable media including CD-R, DVD-R, CD-RW, DVD-RW, DVD+R, DVD+R DL.

The command!

cmdburn [command] <options>
Where command is one of: burn, eject, load, erase or fullerase
and <options> is one or more of: /f [filepath], /d [dirpath], /l [label], /erase, /eject, /fullerase or /noexit where:
/f [filepath] is the name of the file you wish to burn
/d [dirpath] is the name of the directory you wish to burn
/l [label] is the new label for the CD / DVD
/erase if you want to erase before burn
/eject if you want to eject after burn
/fullerase if you want to perform a full erase before burn (warning: this could take a long time depending on the size of the disk)
/noexit if you want to return to interactive mode when the batch process is completed
/hide if you want hide the user interface during operation
/prompterase (use with burn command) if you want to prompt the user when erasing a disc that already contains data -
--do not use with /hide
/popuperror (use with burn command) if you wish to display a popup if an error occurs - do not use with /hide
/? if you want to see this usage information


Command line examples

>cmdburn burn /f c:\potato\tomato.doc This will burn the file c:\potato\tomato.doc to cd.

>cmdburn burn /f c:\potato\tomato.doc /l BCKUP /eject This will burn the file c:\potato\tomato.doc to cd, label the CD "BCKUP"
and eject the CD when burning has finished.

>cmdburn burn /d c:\backup /l BCK_CD /eject will burn the contents of C:\backup to a CD, label the CD as "BCK_CD"
and will eject the disc when finished.

>cmdburn burn /d c:\backup /l CmdBn /erase /eject will first erase the CD,
then burn the contents of C:\backup, label the CD as "CmdBn" and will eject the disc when finished.

regards
Uwe :D
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: Burn files to CD/DVD

Postby Silvio.Falconi » Fri Jul 08, 2016 4:16 pm

I thinked natter need something ton insert on fwh application no extern....

if you download Nero you can use the class or Nero ....
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7056
Joined: Thu Oct 18, 2012 7:17 pm

Re: Burn files to CD/DVD

Postby Natter » Fri Jul 08, 2016 7:12 pm

Uwe, thank !
I was interested to write on CD media FW. If not, use an external application
Natter
 
Posts: 1216
Joined: Mon May 14, 2007 9:49 am

Re: Burn files to CD/DVD

Postby FranciscoA » Sat Jul 09, 2016 3:33 am

I found this Mister Antonio's sample. May be help you.
Code: Select all  Expand view
#include "FiveWin.ch"

#define  HKEY_CURRENT_USER  0x80000001

function Main()

   local oCDRec := TCDRec():New()
   local oReg32, cValue
   
   MsgInfo( oCDRec:IsAvailable() )
   
   MsgInfo( oCDRec:GetDrive() )

   oReg32 = TReg32():New( HKEY_CURRENT_USER,;
                          "Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" )
   oReg32:Get( "CD Burning", @cValue )
   MsgInfo( cValue )
   oReg32:Close()

   // MsgInfo( oCDRec:GetPath() )

   // aqui llamar al método addfile por cada fichero

   oCDRec:Burn()
   
   oCDRec:End()

   MsgInfo( "ok" )

return nil

CLASS TCDRec

   DATA   hCD
   DATA   aFiles
   
   METHOD New()
   
   METHOD AddFile( cFile ) VIRTUAL
   
   METHOD GetSize() VIRTUAL
   
   METHOD IsAvailable() INLINE CDAvailable( ::hCD )
   
   METHOD GetDrive() INLINE CDDrive( ::hCD )
   
   METHOD GetPath() INLINE CDGetPath()
   
   METHOD Burn( hWnd ) INLINE CDBurn( ::hCD )
   
   METHOD End() INLINE CoUninitialize()
   
ENDCLASS  

METHOD New() CLASS TCDRec

   CoInitialize()

   ::hCD = CDInit()
   
   ::aFiles := {}
   
return Self  
Francisco J. Alegría P.
Chinandega, Nicaragua.

Fwxh-MySql-TMySql
User avatar
FranciscoA
 
Posts: 2158
Joined: Fri Jul 18, 2008 1:24 am
Location: Chinandega, Nicaragua, C.A.

Re: Burn files to CD/DVD

Postby Silvio.Falconi » Sat Jul 09, 2016 7:44 am

Perhaps we need some functions ? ( or are on fwh libs ?)
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7056
Joined: Thu Oct 18, 2012 7:17 pm

Re: Burn files to CD/DVD

Postby Massimo Linossi » Sat Jul 09, 2016 6:41 pm

Great Uwe !!!
Works perfectly. Thanks a lot.
User avatar
Massimo Linossi
 
Posts: 498
Joined: Mon Oct 17, 2005 10:38 am
Location: Italy


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 77 guests