On my pc I have a dvd (samsung) and a cd burner(plextor).

I'm using MCI to access to my cdrom
I'm writing a program that open, with mci, the cdaudio device, read the total number of track and the size of each track on a cd audio. The program worked fine till yesterday.
Now, when I try to send MCI_STATUS to the dvd, the system replies with MCIERR_HARDWARE
When I send command to the cdburner the program works.

Why???? I didn't any change neither to my hardware nor to the function that sends command to the dvd
Posted on 2003-12-08 15:56:42 by greenant
i have combo dvd/cdrw (lg). attach your code. i try it.
Posted on 2003-12-22 21:12:17 by P2M
My code is in c++.
I will translate it to assembly and post it
Posted on 2003-12-23 01:49:09 by greenant
What code does not work C or Asm?
i like C more then Asm.
Posted on 2003-12-23 02:59:43 by P2M
I usually code in asm but now I have to pass a c++ exam at the university, so I'm learning c++.
This project is written in c++ but it is easy to convert to asm because I don't use may high-level things.

I don't know why, but this code now works. It is very strage.
I can post the code



/////////////////////////////////////////////////////////////////////
//
// Legge i dati dal lettore cd e riempie le variabili
//
// INPUT:
// hWnd HWND della finestra genitore
// DriveLetter lettera identificativa del drive da leggere
//
//
bool ASPILeggiCd (HWND hWnd, char DriveLetter)
{
UINT wDeviceID; //Device Id del lettore cd
DWORD dwReturn; //Valore di ritorno della chiamate MCI

char buffer[256]; //Buffer temporaneo per le operazioni di stringa
char DrivePath[8]; //Path del drive da aprire

//Strutture usate da MCI
MCI_OPEN_PARMS mciOpenParms;
MCI_SET_PARMS mciSetParms;
MCI_STATUS_PARMS mciStatusParms;


wsprintf(DrivePath, "%c:\\", DriveLetter); //Crea la path del drive da aprire

//Apre il cd audio
ZeroMemory(&mciOpenParms, sizeof(mciOpenParms));
mciOpenParms.lpstrDeviceType = (LPCSTR) MCI_DEVTYPE_CD_AUDIO;
mciOpenParms.lpstrElementName = DrivePath;
if (dwReturn = mciSendCommand(NULL, MCI_OPEN,
MCI_OPEN_ELEMENT | MCI_OPEN_TYPE | MCI_OPEN_TYPE_ID,
(DWORD)(LPVOID) &mciOpenParms))
{
//Errore nell'apertura del dispositivo
mciGetErrorString(dwReturn, buffer, sizeof(buffer));
MessageBox(hWnd, buffer, AppName, MB_OK | MB_ICONERROR);
return FALSE;
}

//Il dispositivo ? stato aperto correttamente
wDeviceID = mciOpenParms.wDeviceID;

//Imposta il formato dei tempi in MSF
mciSetParms.dwTimeFormat = MCI_FORMAT_MSF;
if (dwReturn = mciSendCommand(wDeviceID, MCI_SET, MCI_SET_TIME_FORMAT,
(DWORD)(LPVOID) &mciSetParms))
{
//Errore nel settare la modalit?
mciGetErrorString(dwReturn, buffer, sizeof(buffer));
MessageBox(hWnd, buffer, AppName, MB_OK | MB_ICONERROR);
mciSendCommand(wDeviceID, MCI_CLOSE, 0, NULL);
return FALSE;
}


//Legge il numero di tracce totali presenti sul cd
mciStatusParms.dwItem = MCI_STATUS_NUMBER_OF_TRACKS;
if (dwReturn = mciSendCommand(wDeviceID, MCI_STATUS, MCI_STATUS_ITEM,
(DWORD)(LPVOID) &mciStatusParms))
{
//Errore durante la lettura delle informazioni
mciGetErrorString(dwReturn, buffer, sizeof(buffer));
MessageBox(hWnd, buffer, AppName, MB_OK | MB_ICONERROR);
mciSendCommand(wDeviceID, MCI_CLOSE, 0, NULL);
return FALSE;
}

//Numero totale di tracce presenti (escluso il lead out)
AlbumCd.TracceNum = (unsigned char) mciStatusParms.dwReturn;

//Dealloca lo spazio precedentemente allocato
if(AlbumCd.Tracce) delete [] AlbumCd.Tracce;

//Alloca spazio per l'array di tracce_cd
AlbumCd.Tracce = new(tracce_cd[AlbumCd.TracceNum]);

//Inserisce le righe nella variabile
for (unsigned char i=1; i<=AlbumCd.TracceNum; i++)
{
//Legge la durata di ogni traccia
mciStatusParms.dwItem = MCI_STATUS_LENGTH;
mciStatusParms.dwTrack = i;
if (dwReturn = mciSendCommand(wDeviceID, MCI_STATUS, MCI_STATUS_ITEM | MCI_TRACK,
(DWORD)(LPVOID) &mciStatusParms))
{
//Errore durante la lettura della lunghezza della traccia
mciGetErrorString(dwReturn, buffer, sizeof(buffer));
MessageBox(hWnd, buffer, AppName, MB_OK | MB_ICONERROR);
mciSendCommand(wDeviceID, MCI_CLOSE, 0, NULL);
return FALSE;
}

wsprintf (buffer, "Traccia %d", i);
lstrcpy(AlbumCd.Tracce[i-1].Nome, buffer);
lstrcpy(AlbumCd.Tracce[i-1].Artista, "Sconosciuto");
AlbumCd.Tracce[i-1].Lunghezza.Minuti = MCI_MSF_MINUTE(mciStatusParms.dwReturn);
AlbumCd.Tracce[i-1].Lunghezza.Secondi = MCI_MSF_SECOND(mciStatusParms.dwReturn);
AlbumCd.Tracce[i-1].Lunghezza.Frame = MCI_MSF_FRAME(mciStatusParms.dwReturn);


//Legge l'offset di ogni traccia
mciStatusParms.dwItem = MCI_STATUS_POSITION;
mciStatusParms.dwTrack = i;
if (dwReturn = mciSendCommand(wDeviceID, MCI_STATUS, MCI_STATUS_ITEM | MCI_TRACK,
(DWORD)(LPVOID) &mciStatusParms))
{
//Errore durante la lettura della lunghezza della traccia
mciGetErrorString(dwReturn, buffer, sizeof(buffer));
MessageBox(hWnd, buffer, AppName, MB_OK | MB_ICONERROR);
mciSendCommand(wDeviceID, MCI_CLOSE, 0, NULL);
return FALSE;
}

AlbumCd.Tracce[i-1].Offset.Minuti = MCI_MSF_MINUTE(mciStatusParms.dwReturn);
AlbumCd.Tracce[i-1].Offset.Secondi = MCI_MSF_SECOND(mciStatusParms.dwReturn);
AlbumCd.Tracce[i-1].Offset.Frame = MCI_MSF_FRAME(mciStatusParms.dwReturn);

}

//Calcola la posizione dell'ultima traccia di leadout
{
unsigned char i = AlbumCd.TracceNum - 1; //Posizione dell'ultima traccia
unsigned long NumberOfSec =
(
(AlbumCd.Tracce[i].Offset.Minuti * 60 * 75) + //Minuti
(AlbumCd.Tracce[i].Offset.Secondi * 75) + //Secondi
(AlbumCd.Tracce[i].Offset.Frame ) + //Frame

(AlbumCd.Tracce[i].Lunghezza.Minuti * 60 * 75) + //Minuti
(AlbumCd.Tracce[i].Lunghezza.Secondi * 75) + //Secondi
(AlbumCd.Tracce[i].Lunghezza.Frame ) + //Frame
1) / 75;

AlbumCd.Tracce[i+1].Offset.Minuti = unsigned short (NumberOfSec / 60);
AlbumCd.Tracce[i+1].Offset.Secondi = unsigned short (NumberOfSec % 60);
}

if (dwReturn = mciSendCommand(wDeviceID,
MCI_CLOSE, 0, NULL))
{
mciGetErrorString(dwReturn, buffer, sizeof(buffer));
MessageBox(hWnd, buffer, AppName, MB_OK | MB_ICONERROR);
return FALSE;
}

AlbumCd.DiscId = cddb_discid(AlbumCd.TracceNum);

AlbumCd.Categoria = 0;
AlbumCd.Genere = 0;
lstrcpy(AlbumCd.Artista, "Sconosciuto");
lstrcpy(AlbumCd.Nome, "Sconosciuto");
AlbumCd.Anno = 0;

return TRUE;
}


Comments are in Italian, but code is easy to understand
Posted on 2003-12-23 05:45:56 by greenant
I don't know why, but this code now works. It is very strage.
Must I check the program on its dvd?
Posted on 2003-12-24 04:06:30 by P2M
I don't understand :confused:
Posted on 2003-12-24 05:08:09 by greenant
app is work?
Posted on 2003-12-24 05:31:56 by P2M
What code does not work C or Asm?
i like C more then Asm.


Why are you here?
Posted on 2003-12-24 06:03:33 by Homer

EvilHomer2k
:confused: This is a private club?

Because winAsm like winC.
Posted on 2003-12-24 06:13:53 by P2M
App is now working

It's about 3 years since I started programming asm under win32.

In october I started university and I must learn c++ in order to pass some exams.
To increase the mark I can code a project.
Since I know well win32asm and is very simple to convert a w32asm program to a c++ one, now I'm using my knowledge to code in c++ using only win32 api (and not class like MFC, ATL, ...).

Now I'm having some problems with my program and I'm asking help here, because this is the only forum where I'm subscribed and where I can get useful answers.
My problems aren't c++ related but only windows related.
I'm not asking c++ specific questions but only windows questions. And these questions can be useful also to programmers that code only in assembler
Posted on 2003-12-24 07:51:20 by greenant
Well said Greenant, this is not a EvilHomer2k?s private side.
Your question is interesting for a lot of people.
ipadilla
Posted on 2003-12-24 12:13:58 by ipadilla