wiliam 发表于 2014-7-28 19:56:12

win32汇编MCI调用的一些问题

本帖最后由 wiliam 于 2014-7-28 20:00 编辑

下面是个可以让系统弹出 光驱的程序,我用open能让他弹出来但让他CLOSE,他却死活不回去了 求大神解答
.386
   .model flat,stdcall
   option casemap:none
include windows.inc
include winmm.inc
includelib winmm.lib;
include gdi32.inc
includelib gdi32.lib
include kernel32.inc
includelib kernel32.lib
include user32.inc
includelib user32.lib
include gdi32.inc
includelib gdi32.lib
include comctl32.inc
includelib comctl32.lib
DLG_MAIN equ   1000h
ICO_MAIN equ   2000h
   .data?
hInstance dd ?;定义模块句柄
dwReSize dd ?
hDevice   dd ?
hWinMain dd ?
   .const
musicName db "ring.wav",0
szDevice db " CDAUDIO",0;CDAUDIO
   .code
_procPlay proc
   local @stMCIOpen:MCI_OPEN_PARMS
   LOCAL   @stMCIPlay:MCI_PLAY_PARMS
   local@stMCIClose:MCI_GENERIC_PARMS
   mov @stMCIOpen.lpstrDeviceType,offset szDevice
   mov @stMCIOpen.lpstrElementName,offset musicName;musicName应该就是音乐文件名吧。
   invoke mciSendCommand,NULL,MCI_OPEN,MCI_OPEN_TYPE,addr @stMCIOpen
   ;mciSendCommand发送消息给MCI设备
   mov eax,@stMCIOpen.wDeviceID
   mov hDevice,eax
    mov eax,hWinMain
   mov @stMCIPlay.dwCallback,eax
   invokemciSendCommand,MCI_ALL_DEVICE_ID,MCI_SET,MCI_SET_DOOR_OPEN,NULL
   invokemciSendCommand,addr hDevice,MCI_CLOSE,NULL,NULL
   ret
_procPlay endp
start:
call _procPlay
invoke ExitProcess,NULL
end start

wiliam 发表于 2014-7-29 16:36:52


includelib winmm.lib;
include gdi32.inc
includelib gdi32.lib
include kernel32.inc
includelib kernel32.lib
include user32.inc
includelib user32.lib
include gdi32.inc
includelib gdi32.lib
include comctl32.inc
includelib comctl32.lib
DLG_MAIN equ   1000h
ICO_MAIN equ   2000h
   .data?
hInstance dd ?;定义模块句柄
dwReSize dd ?
hDevice   dd ?
hWinMain dd ?
DeviceIDC dd ?
   .const
szDevice db " CDAUDIO",0;CDAUDIO
   .code
_procPlay proc
   local @stMCIOpen:MCI_OPEN_PARMS
   LOCAL   @stMCIPlay:MCI_PLAY_PARMS
   invokeRtlZeroMemory,addr @stMCIOpen,sizeof @stMCIOpen
   mov @stMCIOpen.lpstrDeviceType,offset szDevice
   invoke mciSendCommand,NULL,MCI_OPEN,MCI_OPE研究了一晚上终于可以让他关闭了,源码附上封贴
.386
   .model flat,stdcall
   option casemap:none
include windows.inc
include winmm.incN_TYPE,addr @stMCIOpen
   ;mciSendCommand发送消息给MCI设备
mov eax,@stMCIOpen.wDeviceID;;*******mov返回的设备名称
push eax
pop DeviceIDC;*****传给DeviceIDC
   invokemciSendCommand,MCI_ALL_DEVICE_ID,MCI_SET,MCI_SET_DOOR_OPEN,NULL
   call _CloseMP3
   ret
_procPlay endp
;************************************************* 关闭CD部分
_CloseMP3 proc _hwnd
local@stMCIClose:MCI_GENERIC_PARMS
invoke RtlZeroMemory ,addr @stMCIClose,sizeof @stMCIClose
mov @stMCIClose.dwCallback,NULL
invoke mciSendCommand, DeviceIDC ,MCI_SET,MCI_SET_DOOR_CLOSED,0
invoke mciSendCommand,DeviceIDC ,MCI_CLOSE,MCI_WAIT,0
ret
_CloseMP3 endp
;*********************************
;***********主程序部分*********
start:
call _procPlay
invoke ExitProcess,NULL
end start
页: [1]
查看完整版本: win32汇编MCI调用的一些问题