I can open an audiocd with MCI with this command


mov mciOpenParms.lpstrDeviceType, MCI_DEVTYPE_CD_AUDIO
invoke mciSendCommand, NULL, MCI_OPEN, MCI_OPEN_TYPE | MCI_OPEN_TYPE_ID, addr mciOpenParms


But If I have two or more cdplayer on my pc, how can I choose to open e:\ instead of d:\ ?
Posted on 2003-12-12 06:57:08 by greenant
greenant
try
...

szDriveE db 'E:\\',0
...
mov mciOpenParms.lpstrAlias,offset szDriveE
invoke mciSendCommand, NULL, MCI_OPEN, ...
Posted on 2003-12-14 22:45:01 by P2M
It doesn't work
Posted on 2003-12-15 03:57:53 by greenant
Afternoon, greenant.

After reading the PSDK, it seems that if you have more than one cd device on your system, then a number will be appended to the device name.
i.e.
If you've got two cdrom drives, then you *should* have:
cdaudio
cdaudio1
inside your system.ini file.

Thus, you might like to try:


.data
mciOpenParms MCI_OPEN_PARMS<?>
cdaudiodevice0 db "cdaudio",0
cdaudiodevice1 db "cdaudio1",0
.code

mov mciOpenParms.lpstrDeviceType, offset cdaudiodevice0
invoke mciSendCommand, NULL, MCI_OPEN, MCI_OPEN_TYPE, addr mciOpenParms
.if eax != 0 ; this device didn't work

mov mciOpenParms.lpstrDeviceType, offset cdaudiodevice1
invoke mciSendCommand, NULL, MCI_OPEN, MCI_OPEN_TYPE, addr mciOpenParms

.endif


NOTE: I haven't tested that code ;)

Cheers,
Scronty
Posted on 2003-12-15 04:26:33 by Scronty
Hy Greenant,

I would like to help you but I have never played with MCI stuff...so it's my first step...

.586
.model flat, stdcall
option casemap:none
;........................................................................
; INCLUDES
;........................................................................

include \masm32\include\windows.inc
include \masm32\include\user32.inc
include \masm32\include\masm32.inc
include \masm32\include\winmm.inc
include \masm32\include\kernel32.inc


includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\masm32.lib
includelib \masm32\lib\winmm.lib

;........................................................................
; DATA
;........................................................................
.data

MsgCaption db "DEBUG",0
MsgBoxText db "OK",0

;MCI_OPEN_PARMS:

dwCallback DWORD 0;
wDeviceID WORD 0;
wReserved0 WORD 0;
lpstrDeviceType DWORD MCI_DEVTYPE_CD_AUDIO;0;
lpstrElementName DWORD 0;
lpstrAlias DWORD 0;

;typedef struct {
; DWORD dwCallback;
; UINT wDeviceID;
; UINT wReserved0;
; LPCSTR lpstrDeviceType;
; LPCSTR lpstrElementName;
; LPCSTR lpstrAlias;
;} MCI_OPEN_PARMS;

;wDeviceID WORD 0;
dwReturn DWORD 0;

mystr db 10 dup(?)
format db "%x",0

.data?

hInstance HINSTANCE ?
CommandLine LPSTR ?

;........................................................................
; CODE
;........................................................................
.code

start:

;int 03h;
push 0
call GetModuleHandle

mov hInstance,eax
call GetCommandLine

mov ebx, MCI_DEVTYPE_CD_AUDIO
mov lpstrDeviceType, ebx

lea eax, dwCallback
push eax
push MCI_OPEN_TYPE or MCI_OPEN_TYPE_ID
push MCI_OPEN
push 0
call mciSendCommand
mov dwReturn, eax

push eax
lea eax, format
push eax
lea eax, mystr
push eax
call wsprintf

push MB_YESNO
lea eax, MsgCaption
push eax
lea eax, mystr; MsgBoxText
push eax
push 0
call MessageBox


push eax
call ExitProcess

end start


The function returns 0 on my system but the CD-PLAYER doesn't open itself.
What's going wrong??

Regards,
fooCoder
Posted on 2003-12-15 04:54:59 by fooCoder
Scronty: it says the device doesn't exist.

Maybe I should use aspi instead of MCI but I don't have documentation
Posted on 2003-12-16 03:17:53 by greenant
greenant
P2M > lpstrAlias
I have allowed mistake.
Need use MCI_OPEN_PARMS.lpstrElementName
137579 - HOWTO: How to Address Multiple CDAudio Devices in Windows NT
Posted on 2003-12-16 19:23:03 by P2M
Thanks. Now it works
But I still have a big problem http://www.asmcommunity.net/board/index.php?topic=16359
Posted on 2003-12-20 15:20:28 by greenant