MCI (Media Control Interface, интерфейс управления аудио-/видео-устройствами) ― универсальный интерфейс, независимый от особенностей аппаратного обеспечения, предназначен для управления аудио-/видео-устройствами. Функции MCI-интерфейса экспортируются из mmsystem.dll. Используются два типа MCI-интерфейса: интерфейс управляющих строк (Command-String Interface), основан на использовании текстовых команд ("open", "play", "close" и т.д.) интерфейс управляющих сообщений (Command-Message Interface). Для управления устройствам посылаются сообщения (MCI_OPEN, MCI_PLAY, MCI_CLOSE и т.д.) mci_SendStringздесь полный текст программы. Файл 02.mp3 лежит в том же каталоге, что и программа, можно добавить OpenFile диалог для выбора mp3-файлов asm-файл Код (ASM): ; GUI # include win64a.inc IDM_MENU equ 37 IDM_OPEN_MP3 equ 100 IDM_PLAY_MP3 equ 101 IDM_QUIT equ 102 IDM_CLOSE_MP3 equ 103 IDM_STOP_MP3 equ 104 .code WinMain proc local msg:MSG xor ebx,ebx mov esi,IMAGE_BASE mov edi,offset ClassName mov ecx,offset CursorName invoke LoadCursorFromFile push rax ;hIconSm push rdi ;lpszClassName push IDM_MENU push COLOR_WINDOW;hbrBackground push rax ;hCursor push rax ;hIcon push rsi ;hInstance push rbx ;cbClsExtra & cbWndExtra pushaddr WndProc ;lpfnWndProc push sizeof WNDCLASSEX;cbSize & style invoke RegisterClassEx,esp ;addr WNDCLASSEX push rbx push rsi ;rsi=400000h shl esi,9 ;rsi=CW_USEDEFAULT push rbx push rbx push 200; высота окна push 400;ширина окна push rsi push rsi sub esp,20h mov r9d,WS_OVERLAPPEDWINDOW or WS_VISIBLE invoke CreateWindowEx,WS_EX_CLIENTEDGE,edi,edi invoke GetMenu,eax mov hMenu,rax lea edi,msg @@: invoke GetMessage,edi,NULL,0,0 invoke DispatchMessage,edi jmp @b WinMain endp WndProc proc hWnd:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM cmp edx,WM_CLOSE je wmCLOSE cmp edx,WM_COMMAND je wmCOMMAND leave jmp NtdllDefWindowProc_ wmCLOSE:invoke RtlExitUserProcess,NULL wmCOMMAND:cmp r8d,IDM_PLAY_MP3 jne @f invoke EnableMenuItem,hMenu,IDM_STOP_MP3,MF_ENABLED invoke EnableMenuItem,hMenu,IDM_CLOSE_MP3,MF_ENABLED invoke EnableMenuItem,hMenu,IDM_PLAY_MP3,MF_GRAYED mov ecx,offset cmd_play jmp @1 @@: cmp r8d,IDM_OPEN_MP3 jne @f invoke EnableMenuItem,hMenu,IDM_PLAY_MP3,MF_ENABLED invoke EnableMenuItem,hMenu,IDM_CLOSE_MP3,MF_ENABLED invoke EnableMenuItem,hMenu,IDM_OPEN_MP3,MF_GRAYED mov ecx,offset cmd_open jmp @1 @@: cmp r8d,IDM_QUIT jne @f invoke SendMessage,,WM_SYSCOMMAND,SC_CLOSE,NULL jmp wmBYE @@: cmp r8d,IDM_STOP_MP3 jne @f invoke EnableMenuItem,hMenu,IDM_STOP_MP3,MF_GRAYED invoke EnableMenuItem,hMenu,IDM_PLAY_MP3,MF_ENABLED mov ecx,offset cmd_stop jmp @1 @@: cmp r8d,IDM_CLOSE_MP3 jne wmBYE invoke EnableMenuItem,hMenu,IDM_CLOSE_MP3,MF_GRAYED invoke EnableMenuItem,hMenu,IDM_PLAY_MP3,MF_GRAYED invoke EnableMenuItem,hMenu,IDM_STOP_MP3,MF_GRAYED invoke EnableMenuItem,hMenu,IDM_OPEN_MP3,MF_ENABLED mov ecx,offset cmd_close @1: invoke mciSendString,,0,0,0 wmBYE: leave retn WndProc endp .data ClassName db "Uncle Remus tales: mciSendString",0 CursorName db "br_Rabbit3.cur",0 cmd_open db 'open 02.mp3 type MPEGVideo Alias MP3',0 cmd_play db 'play MP3',0 cmd_stop db 'stop MP3',0 cmd_close db 'close MP3',0 hMenu dq ? end rc-файл Код (Text): #include "resource.h" #define IDM_MENU 37 #define IDM_OPEN_MP3 100 #define IDM_PLAY_MP3 101 #define IDM_QUIT 102 #define IDM_CLOSE_MP3 103 #define IDM_STOP_MP3 104 IDM_MENU MENU BEGIN POPUP "MP3-Files" BEGIN MENUITEM "Open",IDM_OPEN_MP3 MENUITEM "Play",IDM_PLAY_MP3,GRAYED MENUITEM "Pause",IDM_STOP_MP3,GRAYED MENUITEM "Close",IDM_CLOSE_MP3,GRAYED MENUITEM SEPARATOR MENUITEM "Exit",IDM_QUIT END END mci_Executeпрограмма аналогична mci_SendString, поэтому только фрагмент Код (ASM): . . . WndProc proc hWnd:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM cmp edx,WM_CLOSE je wmCLOSE cmp edx,WM_COMMAND je wmCOMMAND leave jmp NtdllDefWindowProc_ wmCLOSE:invoke RtlExitUserProcess,NULL wmCOMMAND:cmp r8d,IDM_PLAY_MP3 jne @f invoke EnableMenuItem,hMenu,IDM_STOP_MP3,MF_ENABLED invoke EnableMenuItem,hMenu,IDM_CLOSE_MP3,MF_ENABLED invoke EnableMenuItem,hMenu,IDM_PLAY_MP3,MF_GRAYED mov ecx,offset cmd_play jmp @1 @@: cmp r8d,IDM_OPEN_MP3 jne @f invoke EnableMenuItem,hMenu,IDM_PLAY_MP3,MF_ENABLED invoke EnableMenuItem,hMenu,IDM_CLOSE_MP3,MF_ENABLED invoke EnableMenuItem,hMenu,IDM_OPEN_MP3,MF_GRAYED mov ecx,offset cmd_open jmp @1 @@: cmp r8d,IDM_QUIT jne @f invoke SendMessage,,WM_SYSCOMMAND,SC_CLOSE,NULL jmp wmBYE @@: cmp r8d,IDM_STOP_MP3 jne @f invoke EnableMenuItem,hMenu,IDM_STOP_MP3,MF_GRAYED invoke EnableMenuItem,hMenu,IDM_PLAY_MP3,MF_ENABLED mov ecx,offset cmd_stop jmp @1 @@: cmp r8d,IDM_CLOSE_MP3 jne wmBYE invoke EnableMenuItem,hMenu,IDM_CLOSE_MP3,MF_GRAYED invoke EnableMenuItem,hMenu,IDM_PLAY_MP3,MF_GRAYED invoke EnableMenuItem,hMenu,IDM_STOP_MP3,MF_GRAYED invoke EnableMenuItem,hMenu,IDM_OPEN_MP3,MF_ENABLED mov ecx,offset cmd_close @1: invoke mci_Execute wmBYE: leave retn WndProc endp .data . . . cmd_open db 'open 02.mp3 type MPEGVideo Alias MP3',0 cmd_play db 'play MP3',0 cmd_stop db 'stop MP3',0 cmd_close db 'close MP3',0 hMenu dq ? mci_SendCommand Код (ASM): . . . MCI_OPEN_PARMS struct dwCallback dq ? wDeviceID dd ? lpstrDeviceType dq ?; lpstrElementName dq ?; lpstrAlias dq ?; MCI_OPEN_PARMS ends MCI_PLAY_PARMS struct dwCallback dq ?; dwFrom dd ? dwTo dd ? MCI_PLAY_PARMS ends . . . WndProc proc hWnd:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM cmp edx,WM_CLOSE je wmCLOSE cmp edx,WM_COMMAND je wmCOMMAND leave jmp NtdllDefWindowProc_ wmCLOSE:invoke RtlExitUserProcess,NULL wmCOMMAND:cmp r8d,IDM_PLAY_MP3 jne @f invoke EnableMenuItem,hMenu,IDM_STOP_MP3,MF_ENABLED invoke EnableMenuItem,hMenu,IDM_CLOSE_MP3,MF_ENABLED invoke EnableMenuItem,hMenu,IDM_PLAY_MP3,MF_GRAYED mov ecx,mciOpenParms.wDeviceID lea r9d,mciPlayParms invoke mciSendCommand,,MCI_PLAY,MCI_NOTIFY jmp wmBYE @@: cmp r8d,IDM_OPEN_MP3 jne @f mov mciPlayParms.dwCallback,rcx movr mciOpenParms.lpstrDeviceType,Mp3Device movr mciOpenParms.lpstrElementName,NameOfFile lea r9d,mciOpenParms invoke mciSendCommand,0,MCI_OPEN,MCI_OPEN_TYPE or MCI_OPEN_ELEMENT invoke EnableMenuItem,hMenu,IDM_PLAY_MP3,MF_ENABLED invoke EnableMenuItem,hMenu,IDM_CLOSE_MP3,MF_ENABLED invoke EnableMenuItem,hMenu,IDM_OPEN_MP3,MF_GRAYED jmp wmBYE @@: cmp r8d,IDM_QUIT jne @f invoke SendMessage,,WM_SYSCOMMAND,SC_CLOSE,NULL jmp wmBYE @@: cmp r8d,IDM_STOP_MP3 jne @f mov ecx,mciOpenParms.wDeviceID invoke mciSendCommand,,MCI_PAUSE,MCI_WAIT,0 invoke EnableMenuItem,hMenu,IDM_STOP_MP3,MF_GRAYED invoke EnableMenuItem,hMenu,IDM_PLAY_MP3,MF_ENABLED jmp wmBYE @@: cmp r8d,IDM_CLOSE_MP3 jne wmBYE mov ecx,mciOpenParms.wDeviceID invoke mciSendCommand,,MCI_CLOSE,0,0 invoke EnableMenuItem,hMenu,IDM_PLAY_MP3,MF_GRAYED invoke EnableMenuItem,hMenu,IDM_CLOSE_MP3,MF_GRAYED invoke EnableMenuItem,hMenu,IDM_STOP_MP3,MF_GRAYED invoke EnableMenuItem,hMenu,IDM_OPEN_MP3,MF_ENABLED wmBYE: leave retn WndProc endp .data . . . mciOpenParms MCI_OPEN_PARMS <> mciPlayParms MCI_PLAY_PARMS <> Mp3Device db "MPEGVideo",0 NameOfFile db "02.mp3",0 hMenu dq ? MCI_Wndфрагмент программы Код (ASM): . . . MCIWNDM_OPEN equ WM_USER + 153 . . . WndProc proc hWnd:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM cmp edx,WM_CLOSE je wmCLOSE cmp edx,WM_COMMAND je wmCOMMAND cmp edx,WM_CREATE je wmCREATE leave jmp NtdllDefWindowProc_ wmCLOSE:invoke RtlExitUserProcess,NULL wmCREATE:invoke MCIWndCreate,,IMAGE_BASE,WS_CHILD,0 mov hwndMovie,rax jmp wmBYE wmCOMMAND:cmp r8d,IDM_PLAY_MP3 jne @f invoke SendMessage,hwndMovie,MCI_PLAY,0,0 invoke EnableMenuItem,hMenu,IDM_STOP_MP3,MF_ENABLED invoke EnableMenuItem,hMenu,IDM_CLOSE_MP3,MF_ENABLED invoke EnableMenuItem,hMenu,IDM_PLAY_MP3,MF_GRAYED jmp wmBYE @@: cmp r8d,IDM_OPEN_MP3 jne @f mov r9d,offset NameOfFile invoke SendMessage,hwndMovie,MCIWNDM_OPEN,0 invoke EnableMenuItem,hMenu,IDM_PLAY_MP3,MF_ENABLED invoke EnableMenuItem,hMenu,IDM_CLOSE_MP3,MF_ENABLED invoke EnableMenuItem,hMenu,IDM_OPEN_MP3,MF_GRAYED jmp wmBYE @@: cmp r8d,IDM_QUIT jne @f invoke SendMessage,,WM_SYSCOMMAND,SC_CLOSE,NULL jmp wmBYE @@: cmp r8d,IDM_STOP_MP3 jne @f invoke SendMessage,hwndMovie,MCI_PAUSE,0,0 invoke EnableMenuItem,hMenu,IDM_STOP_MP3,MF_GRAYED invoke EnableMenuItem,hMenu,IDM_PLAY_MP3,MF_ENABLED jmp wmBYE @@: cmp r8d,IDM_CLOSE_MP3 jne wmBYE invoke SendMessage,hwndMovie,MCI_CLOSE,0,0 invoke EnableMenuItem,hMenu,IDM_CLOSE_MP3,MF_GRAYED invoke EnableMenuItem,hMenu,IDM_PLAY_MP3,MF_GRAYED invoke EnableMenuItem,hMenu,IDM_STOP_MP3,MF_GRAYED invoke EnableMenuItem,hMenu,IDM_OPEN_MP3,MF_ENABLED wmBYE: leave retn WndProc endp .data . . . hwndMovie dq ? NameOfFile db "02.mp3",0 hMenu dq ? Во вложении asm/rc/exe/cur/mp3-файлы К сожалению, здесь приведена только работа с mp3-файлом и я не нашел, как напрямую работать с mp3 в ресурсах или в памяти, не создавая для этого временные файлы...