How to open CD-ROM using Asm?
Posted on 2001-09-23 04:17:54 by AntiLamer
;------------------------------------------------------------------------------
; API "mciSendCommandA" here opens the device
;------------------------------------------------------------------------------
mov open_lpstrDeviceType,516 ;fill MCI_OPEN_PARMS structure
;MCI_DEVTYPE_CD_AUDIO = 516
push OFFSET open_dwCallback ;dwParam, address MCI_OPEN_PARMS struc.
push 3100h ;fdwCommand, MCI_OPEN_TYPE = 2000h
; MCI_OPEN_TYPE_ID = 1000h
; MCI_OPEN_SHAREABLE = 100h
push 0803h ;uMsg, command message, MCI_OPEN
push 0h ;IDDevice, not used with MCI_OPEN
call mciSendCommandA ;- API Function -


;------------------------------------------------------------------------------
; API "mciSendCommandA" here stops playing the current track
;------------------------------------------------------------------------------
push OFFSET generic_dwCallback;dwParam, MCI_GENERIC_PARMS structure
push 0h ;fdwCommand, 0h=no command
push 0808h ;uMsg, message to send (MCI_STOP)
push open_wDeviceID ;IDDevice, given from MCI_OPEN
call mciSendCommandA ;- API Function -
;------------------------------------------------------------------------------
; API "mciSendCommandA" here releases access to a device or file.
;------------------------------------------------------------------------------
push OFFSET generic_dwCallback;dwParam, MCI_GENERIC_PARMS structure
push 0h ;fdwCommand, 0h=no command
push 804h ;uMsg, message to send (MCI_CLOSE)
push open_wDeviceID ;IDDevice, given from MCI_OPEN
call mciSendCommandA ;- API Function -



;------------------------------------------------------------------------------
; API "mciSendCommandA" here opens the cdrom door
;------------------------------------------------------------------------------
push OFFSET set_dwCallback ;dwParam, address MCI_SET_PARMS struc.
push 0100h ;fdwCommand, MCI_SET_DOOR_OPEN
push 080Dh ;uMsg, command message, MCI_SET
push open_wDeviceID ;IDDevice, given from MCI_OPEN
call mciSendCommandA ;- API Function -



;------------------------------------------------------------------------------
; API "mciSendCommandA" here closes the cdrom door
;------------------------------------------------------------------------------
My_mciSendCommandClose:
push OFFSET set_dwCallback ;dwParam, address MCI_SET_PARMS struc.
push 0200h ;fdwCommand, MCI_SET_DOOR_CLOSED
push 080Dh ;uMsg, command message, MCI_SET
push open_wDeviceID ;IDDevice, given from MCI_OPEN
call mciSendCommandA ;- API Function -



more at http://www.crahkob.com/td


TD
Posted on 2001-09-23 05:36:41 by Test Department
Test,

very useful example.
But how i get this

open_wDeviceID ? ;


thanks
Posted on 2001-09-23 11:20:49 by Bit7
open_wDeviceID is part of MCI_OPEN_PARMS structure.
If you open the device you get it.

.data?
align 4
; - MCI_OPEN_PARMS Structure ( API=mciSendCommand ) -
open_dwCallback dd ?
open_wDeviceID dd ?
open_lpstrDeviceType dd ?
open_lpstrElementName dd ?
open_lpstrAlias dd ?


; - MCI_SET_PARMS Structure ( API=mciSendCommand ) -
set_dwCallback dd ?
set_dwTimeFormat dd ?
set_dwAudio dd ?


; - MCI_PLAY_PARMS Structure ( API=mciSendCommand ) -
play_dwCallback dd ?
play_dwFrom dd ?
play_dwTo dd ?


; - MCI_GENERIC_PARMS Structure ( API=mciSendCommand ) -
generic_dwCallback dd ?


; - MCI_STATUS_PARMS Structure ( API=mciSendCommand ) -
status_dwCallback dd ?
status_dwReturn dd ?
status_dwItem dd ?
status_dwTrack dd ?


TD
Posted on 2001-09-23 12:37:27 by Test Department
tanks
Posted on 2001-09-24 14:05:39 by Bit7
does anyone know how to check if cdrom's door are opened or closed???

bye
Posted on 2002-01-31 09:42:26 by NEMO
I've not tested, but I thought that you could try to read something on a CD drive (you can read for a specified file that you know it's not present on the CD) then you'll get an error.

And maybe the error would be different if the CD drive is opened or closed. But I'm not very sure, but maybe the return error will be different (maybe 'file not found' if it's closed and maybe 'can't access to drive' if it's opened <-- these error messages are not true, because I don't know the message of the real errors :alright: )

So try, and if it works, write the code here :) .
I would be glad to see if my suggestion if right or wrong !:alright:
Posted on 2002-01-31 13:56:18 by Vom-bonjour:-()
.data
OpenCD db"Set cdaudio door open wait",0
CloseCD db "Set cdaudio door closed wait",0

.code

call mciSendStringA,offset OpenCD,0,0,0 ;- open

call mciSendStringA,offset CloseCD,0,0,0 ;- close
Posted on 2002-01-31 16:08:15 by Max
Max, i know how to open/close cd. i want to check what is the current state of cd, is it opened or cloesed.

Vom-bonjour:-() i'll try that, thanx.


cya
Posted on 2002-01-31 19:18:07 by NEMO
I do not have those functions in my Win32.hlp, where are them?
Posted on 2002-01-31 19:55:05 by CodeLover
the mciSendCommandA or mciSendStringA are in MMEDIA.HLP
Posted on 2002-01-31 20:45:40 by NEMO
NEMO is looks like you can send the MCIWNDM_CAN_EJECT message to get the status of the cd tray. it will return true or false depending if it open or closed.
Posted on 2002-01-31 21:14:54 by smurf
Hi Nemo,

check the status of the device to get that info :



;------------------------------------------------------------------------------
; API "mciSendCommandA" here retrieves infos about current mode of the device
;------------------------------------------------------------------------------
mov status_dwItem,04h ;structure, MCI_STATUS_MODE
push OFFSET status_dwCallback;dwParam, MCI_STATUS_PARMS structure
push 0104h ;fdwCommand,
;MCI_STATUS_ITEM = 0100h
;MCI_STATUS_MODE = 04h
push 0814h ;uMsg, command message, MCI_STATUS
push open_wDeviceID ;IDDevice, given from MCI_OPEN
call mciSendCommandA ;- API Function -
cmp status_dwReturn,530 ;check if door is open, MCI_MODE_OPEN=530



TD
Posted on 2002-02-01 03:04:22 by Test Department
hi

smurf:
yes i can send MCIWNDM_CAN_EJECT message but first i have to create MCI Window that will be associate with "CDAudio" device.
And then send MCIWNDM_CAN_EJECT message but for cdroms it will almost allways return TRUE.
so it want work.:(

Test Department:
i've check this earlier, it's from one of yours example :grin: , but it only works if there is some compact disc in my cdrom. it almost works, but i need to check if cdrom's door are opened or closed with no meter that compact disc is or isn't in cd-drive.



We'll gonna find the anwser, there's nothing impossble!
Posted on 2002-02-01 05:07:33 by NEMO
Yes, I encounter that too.
It also happens with the player included in Win98SE.
Also I can not open the CDRom door via software if no CD is inside !
So, I give it up...

But sure, there must be a solution.

good luck

TD
Posted on 2002-02-01 08:22:03 by Test Department
i've attach my soure, its a RadASM project that i've been making becouse i was boring and wanted to know some thing new about listviews and few others things. maybe u'll have some suggestions.

cya
Posted on 2002-02-01 11:31:28 by NEMO
forgot to atach, how sily of me :grin:
:stupid:

UPDATE:
i've updated a litlle this, so download it once more if you wish
Posted on 2002-02-01 11:33:08 by NEMO
i've got an idea but i'm not quite shure how to do this but i think it may work....
maybe when i'll use IN / OUT will work, i've never use those two commands and i don't how to use them or how to get specifed ports and values maybe someone can point me to some info or anything....
just write your suggestions:)
Posted on 2002-02-02 08:00:41 by NEMO