CD/DVD writing question

vbimport

#1

I am trying to figure out why I cann’t read a audio cd/dvd using this program I wrote.


#include <windows.h>
#include <iostream>
 
 
int main()
{
int num ;
const int buff_size = 2048 ;
byte bootsectorbytes[2*buff_size] ;
DWORD bytesWritten = 0 ;
DWORD bytesRead = 0 ;
HANDLE hFile , hFile2 ;
 
hFile = CreateFile("\\\\.\\d:",GENERIC_READ|GENERIC_WRITE , FILE_SHARE_READ|FILE_SHARE_WRITE,NULL,OPEN_EXISTING ,FILE_ATTRIBUTE_NORMAL,NULL);
std::cout << GetLastError() ;
int i ;
std::cin >> i;
MessageBox(NULL, (LPCSTR)"Error" , (LPCSTR)L"Error Message" ,0 ) ;
//DeviceIoControl(hFile,IOCTL_STORAGE_EJECT_MEDIA,0,0,0,0,&bytesWritten,0);
//DeviceIoControl(hFile,IOCTL_STORAGE_LOAD_MEDIA,0,0,0,0,&bytesWritten,0);
hFile2 = CreateFile("C:\\bootsector.bin",GENERIC_READ|GENERIC_WRITE, FILE_SHARE_READ|FILE_SHARE_WRITE,NULL,OPEN_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL);
DWORD pointer_res = SetFilePointer(hFile, 2048 * 16, NULL, FILE_BEGIN);
std::cout << pointer_res << "
" ;
std::cout << GetLastError() ;
std::cin >> i;
long totalbytesread = 0 ;
while( totalbytesread < buff_size )
{
BOOL b = ReadFile(hFile , &bootsectorbytes , buff_size , &bytesRead , NULL ) ;
totalbytesread += bytesRead ;
//std::cout << "This is an error:" << GetLastError() << "
" ;
//std::cout << "Bytes read: " << totalbytesread << "
" ;
//std::cout << "ReadFile returns " << b << "
" ;
//int j ;
//std::cin >> i ; //j ;
if( b == TRUE && bytesRead != 0 )
WriteFile(hFile2,&bootsectorbytes,(DWORD)bytesRead,&bytesRead,NULL);
else
std::cout << "This is totalbytesread:" << totalbytesread << "
" ;
//(sizeof(bootsectorbytes))
}
 
std::cout << "enter a formated disk" ;
std::cin >> num ;
CloseHandle(hFile);
CloseHandle(hFile2);
}

It ejects fine and I can read any cd/dvd that is NOT an audio cd?
So how can I get my program to read audio cd’s?

Basically I am reading the cd/dvd to a file .iso.

Thanks for any help and sorry about the messy code I was trying alot of different thing’s.