We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

VB.Net Create ISO File

Medium Priority
3,279 Views
Last Modified: 2014-03-24
Hello guys,

I am trying to determine how to save an ISO file of a CD image, though VB.Net...  My goal is to have a system to backup CD's and DVD's (Data, not movie) to our server here at work, and another a way to burn them back down to media if needed.

We run a shop where we fix a lot of computers - and want to make a vault of the 'Recovery Disks' provided with some systems.  After I can get the DVD -> ISO and ISO -> DVD (or CD) working, I will implement a feature to look for manufacture, model, etc.

Any idea's on the first part, Creating the ISO?  I would like to have a status bar as well - killing my original thought of a command-line background process...

Thanks for any solutions - sample code, please.

Andrew
Comment
Watch Question

Top Expert 2010

Commented:
<<  am trying to determine how to save an ISO file of a CD image >>

If you already have the CD that contains the image you just open the volume for direct access and read it like any normal file and save it as .ISO extension.

Here is how you can do this using API: (note: You will need admin privileges)

1) Open the cd volume for direct access. Use these flags below for cdrom. (e: would be the CDROM letter)
hDevice = CreateFileW("\\?\e:", GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0)
2) Create a new file that you will write the image to. Use flags below.
hFile = CreateFileW("d:\my.iso", GENERIC_WRITE, FILE_SHARE_READ Or FILE_SHARE_WRITE, 0, CREATE_ALWAYS, 0, 0)
3) Signals the file system driver not to perform any I/O boundary checks on partition read or write calls.
DeviceIoControl(hDevice, FSCTL_ALLOW_EXTENDED_DASD_IO, 0, 0, 0, 0, dwBytes, 0)

4)Just read the device like a regular file. Make sure to read the file in chunks a good buffer size would be 64KB.

ReadFile(hDevice, Buffer, BufferSize, dwRead, 0)
WriteFile(hFile, ByVal Buffer, dwRead, dwWritten, 0)

5)When your done reading and writing from the device finish by flushing the file and closing the handles.

Call FlushFileBuffers(hDevice)
CloseHandle(hFile)
CloseHandle(hDevice)
Top Expert 2010

Commented:
' Handle to the file you created NOT the device handle like is shown in the above example. Can't belive I missed that before posting.
Should be:
Call FlushFileBuffers(hFile)

Author

Commented:
I will give this a better look in the morning, but to be sure we are on the same page, this will allow me to make an ISO image of the disk, correct?  Almost read like perhaps I did not state this well enough, but again I will look at your sample in the morning.

Thank you,
Andrew
Top Expert 2010
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION

Author

Commented:
Thanks
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.