Click here to Skip to main content
11,412,833 members (74,634 online)
Click here to Skip to main content

Write a UDF CDR

, 22 Jul 2003 CPOL
Rate this:
Please Sign up or sign in to vote.
How to write a CDR in UDF


Some electronic devices need to use CDR as storage media, and you have to append several files each time before the space is used out. In this case, UDF is a good solution, since for each writing, only 7 logic blocks of overhead are used. (Multisession CDs use several minutes for each session's leadout)


How to use the demo

(You need WNASPI32.dll to run the demo, which could be downloaded from Ahead.)

  • Select the CDR drive you want to write to.
  • Insert a blank disc, "Format" it.
  • Browse to select files, and write to the disc. (Now you can view the files using DirectCD).
  • You can list the content of the CDR, and restore files to hard disk
  • Close Session, now any CD drive can read it..


How to use the source code

//Create a variable for your drive
SCSI2 m_drive;
//m_HA:HostAdpaterNumber,m_ID:SCSI ID,m_LUN:LogicUnitNumber
//For a blank CDR, you need to format it 
//Then you can write files onto it
//Append more files here...
//After you have writen ALL the files, close the session
//Now it's readable by regular CDROM drive.


Some useful functions

SCSIRead()      //Read data from CDR
WritePacket()      //Write packets to CDR
ReadTrackInfo()      //Read track info, like next writable address
ReadDiskInfo()      //Read disc info, like capacity
TestUnitReady()      //See if the drive is ready
LoadUnload()      //Eject/Close the tray
SetWriteParameters()    //Set write mode
SCSISetSpeed()      //Set read/write speed
ListFiles()      //List files on the CDR
SaveFileAs()      //Save file on CDR to hard disk

If you want to know more inside stuff

Things you need to have:

  • SCSI command block structure (ANSI X3.131-1994)
  • SCSI multimedia commands-2 (ANSI NCITS 333-2000)
  • OSTA specs: ECMA-167, Universal Disk Format Specification, ECMA-119

Things you need to know:

  • SCSI2 block command structure
  • Use of ASPI
  • Concepts about CDR: track, session, logical blocks, PMA, ATIP, TOC, write modes...
  • UDF(Volume structure, file system)

More info at my website.

Revision History

  • Ver 1.01
    • More comments, some code clean up
    • New function: ListFiles()
    • New function: SaveFileAs()
  • Ver 1.02
    • Some changes on the demo application


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

United States United States
Wheels I reinvented on various embedded systems

*License Plate Reader
*TCP/IP stack
*Web Server
*Ethernet/SCSI/USB drivers
*FAT32/UDF file system
*JPEG/MJPEG encoder

Comments and Discussions

GeneralNot working in Release mode Pin
Abinash Mohanty at 17-Aug-09 20:23
memberAbinash Mohanty17-Aug-09 20:23 
GeneralRe:DVD-RAM FAT32 format in xp Pin
rrbhuvan at 10-Aug-07 5:33
memberrrbhuvan10-Aug-07 5:33 
Generalno load Pin
bose_sard at 24-Nov-05 20:16
memberbose_sard24-Nov-05 20:16
QuestionHow many copies make by the CDR Pin
ThangaDharma at 5-Oct-05 8:22
memberThangaDharma5-Oct-05 8:22 
GeneralClose Session Problem Pin
gzu53 at 23-Aug-05 5:24
membergzu5323-Aug-05 5:24 
GeneralCode corrections Pin
nico04 at 18-Aug-04 23:18
membernico0418-Aug-04 23:18 
QuestionHow to append files to a UDF CDR Pin
jacmod at 10-Aug-04 18:46
memberjacmod10-Aug-04 18:46 
AnswerClose session Error: Pin
jacmod at 25-Aug-04 18:52
memberjacmod25-Aug-04 18:52 
GeneralError in "Write Files" Process Pin
jacmod at 5-Jul-04 23:30
memberjacmod5-Jul-04 23:30 
GeneralRe: Error in "Write Files" Process Pin
Anonymous at 15-Jul-04 21:34
sussAnonymous15-Jul-04 21:34 
GeneralRe: Error in "Write Files" Process Pin
jacmod at 28-Jul-04 18:19
memberjacmod28-Jul-04 18:19 
GeneralRe: Error in "Write Files" Process Pin
Anonymous at 29-Jul-04 2:28
sussAnonymous29-Jul-04 2:28 
GeneralRe: Error in "Write Files" Process Pin
jacmod at 10-Aug-04 18:29
memberjacmod10-Aug-04 18:29 
GeneralError in SetWriteParameters() function Pin
sunil samineni at 24-Jun-04 1:37
membersunil samineni24-Jun-04 1:37 
GeneralRe: Error in SetWriteParameters() function Pin
fullluck at 1-Jul-04 22:28
memberfullluck1-Jul-04 22:28 
Generalexplain note 4 in ATAPI code fix Pin
fkking at 25-May-04 14:13
sussfkking25-May-04 14:13 
GeneralRe: explain note 4 in ATAPI code fix Pin
fullluck at 27-May-04 2:20
memberfullluck27-May-04 2:20 
GeneralRe: explain note 4 in ATAPI code fix Pin
fkking at 28-May-04 11:27
memberfkking28-May-04 11:27 
QuestionWhat's mean this error code? Pin
holysky100 at 19-May-04 20:20
memberholysky10019-May-04 20:20 
AnswerRe: What's mean this error code? Pin
fkking at 25-May-04 14:15
sussfkking25-May-04 14:15 
GeneralDVD RAM Format Pin
Anonymous at 12-May-04 6:48
sussAnonymous12-May-04 6:48 
GeneralRe: DVD RAM Format Pin
nico04 at 16-Aug-04 5:24
membernico0416-Aug-04 5:24 
GeneralRe: DVD RAM Format Pin
KenThompson at 10-Mar-08 4:07
memberKenThompson10-Mar-08 4:07 
GeneralCD writer is not detecting Pin
Prashant N at 12-Apr-04 21:39
sussPrashant N12-Apr-04 21:39 
GeneralLast block information Pin
kiran_12 at 8-Apr-04 3:47
memberkiran_128-Apr-04 3:47 
Questionhow to write a directory Pin
nicho at 9-Mar-04 23:00
membernicho9-Mar-04 23:00 
GeneralDisc manufacturer Pin
Anonymous at 13-Feb-04 13:39
sussAnonymous13-Feb-04 13:39 
Generalsample code is not for ATAPI drive, suggested fixes Pin
fkking at 17-Jan-04 14:23
memberfkking17-Jan-04 14:23 
GeneralWrite Error Pin
pigy at 30-Nov-03 22:22
memberpigy30-Nov-03 22:22 
QuestionWhat mmc command not support ATAPI? Pin
Anonymous at 9-Nov-03 17:26
sussAnonymous9-Nov-03 17:26 
GeneralFormat a CDR with DELPHI Pin
miximax at 19-Aug-03 5:14
membermiximax19-Aug-03 5:14 
GeneralSector Write in CD Pin
samesky at 16-Aug-03 21:59
membersamesky16-Aug-03 21:59 
Generalburning a CD-R disk using a packet-writing Pin
RPMcoffee at 14-Jul-03 18:10
memberRPMcoffee14-Jul-03 18:10 
GeneralRe: burning a CD-R disk using a packet-writing Pin
Hongfeng at 16-Jul-03 7:51
memberHongfeng16-Jul-03 7:51 
GeneralRe: burning a CD-R disk using a packet-writing Pin
RPMcoffee at 21-Jul-03 5:23
memberRPMcoffee21-Jul-03 5:23 
GeneralRe: burning a CD-R disk using a packet-writing Pin
Hongfeng at 23-Jul-03 11:21
memberHongfeng23-Jul-03 11:21 
GeneralRe: burning a CD-R disk using a packet-writing Pin
RPMcoffee at 23-Jul-03 18:16
memberRPMcoffee23-Jul-03 18:16 
Generalfound au dio cd burner source code Pin
Anonymous at 28-Mar-03 15:00
sussAnonymous28-Mar-03 15:00 
Questionwhat is your OS? (null) Pin
Anonymous at 6-Feb-03 21:31
sussAnonymous6-Feb-03 21:31 
Anonymous at 6-Feb-03 16:26
sussAnonymous6-Feb-03 16:26 
QuestionHow to read VAT ICB? Pin
Anonymous at 5-Feb-03 14:27
sussAnonymous5-Feb-03 14:27 
AnswerRe: How to read VAT ICB? Pin
Hongfeng at 6-Feb-03 5:16
memberHongfeng6-Feb-03 5:16 
GeneralRe: How to read VAT ICB? Pin
chimpanzeeVN at 21-Oct-03 0:55
memberchimpanzeeVN21-Oct-03 0:55 
GeneralRe: How to read VAT ICB? Pin
Anonymous at 21-Oct-03 17:16
sussAnonymous21-Oct-03 17:16 
QuestionWhy Can I Record CD? Pin
ryushark at 27-Jan-03 15:36
memberryushark27-Jan-03 15:36 
AnswerRe: Why Can I Record CD? Pin
Christian Graus at 27-Jan-03 15:48
memberChristian Graus27-Jan-03 15:48 
GeneralRe: Why Can I Record CD? Pin
Mike Nordell at 27-Jan-03 16:48
memberMike Nordell27-Jan-03 16:48 
GeneralDemo Project File Problem -- no rc file Pin
Anonymous at 27-Jan-03 5:28
sussAnonymous27-Jan-03 5:28 
GeneralRe: Demo Project File Problem -- no rc file Pin
ryushark at 27-Jan-03 15:28
memberryushark27-Jan-03 15:28 
GeneralATAPI Pin
Codegg1234 at 9-Dec-02 9:19
memberCodegg12349-Dec-02 9:19 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.150427.1 | Last Updated 23 Jul 2003
Article Copyright 2002 by spotofleopard
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid