2007-09-16

cd2iso

The magic of creating CD ISO files under Windows


/* This program has been compiled with VC6 and tested under Windows XP SP2 */
#include
#include

int main ( int argc, char ** argv )
{
FILE * f, * out;
char buf[512];
unsigned len;

if (argc != 2)
{
fprintf( stderr, "Syntax: rdiso filename\n" );
return 1;
}

if ( (f = _fsopen( "\\\\?\\CdRom0", "rb", _SH_DENYNO )) == NULL)
{
fprintf( stderr, "Can't open CdRom0\n" );
return 1;
}

if ( (out = fopen( argv[1], "wb" )) == NULL)
{
fprintf( stderr, "Can't open %s\n", argv[1] );
return 1;
}

do
{
len = fread( buf, 1, sizeof(buf), f );
if (len)
fwrite( buf, 1, len, out );
}
while (len == sizeof(buf));
fclose( f );
fclose( out );
return 0;
}

1 則留言:

Arrakeen 提到...

沒想到轉iso這麼簡單。 XD