Link to home
Start Free TrialLog in
Avatar of Crazy_Penguins
Crazy_Penguins

asked on

VB.Net Create ISO File

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
Avatar of Crazy_Penguins
Crazy_Penguins

ASKER

<<  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)
' 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)
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
ASKER CERTIFIED SOLUTION
Avatar of nffvrxqgrcfqvvc
nffvrxqgrcfqvvc

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks