我从网上找到的 这个程序有错误!编译事是两个!请大家帮我弄一下啊!最好装载一个文件夹里,在个我传过来!
我想学学播放音乐的代码!我是初学者,真的很想学!拜托大家了啊!
这里要是有东北大学的,我就去拜师!哈哈·
.386
.model flat, stdcall
option casemap :none
include h:/masm32/include/windows.inc
include h:/masm32/include/user32.inc
includelib h:/masm32/lib/user32.lib
include h:/masm32/include/kernel32.inc
includelib h:/masm32/lib/kernel32.lib
include h:/masm32/include/Gdi32.inc
includelib h:/masm32/lib/Gdi32.lib
include h:/masm32/include/winmm.inc
includelib h:/masm32/lib/winmm.lib
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; Equ 等值定义
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
IDR_MID1 equ 1000
IDI_ICON1 equ 102
IDD_DIALOG1 equ 103
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; 数据段
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
.data?
hInstance dd ?
hWinMain dd ?
hDevice dd ?
szFile db MAX_PATH dup (?)
.const
szResType db 'MID',0
szDevice db 'Sequencer',0
szFileName db '~PA',0
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; 代码段
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
.code
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
_PlayMID proc
local @stMCIOpen:MCI_OPEN_PARMS
local @stMCIPlay:MCI_PLAY_PARMS
local @hResInfo,@dwResSize,@lpRes
local @hFile,@dwTemp
;====================================================
;载入资源
invoke FindResource,hInstance,IDR_MID1,addr szResType
mov @hResInfo,eax
invoke SizeofResource,hInstance,@hResInfo
mov @dwResSize,eax
invoke LoadResource,hInstance,@hResInfo
invoke LockResource,eax
mov @lpRes,eax
;建立文件
invoke GetTempPath,MAX_PATH,addr szFile
invoke lstrcat,addr szFile,addr szFileName
invoke MessageBox,NULL,addr szFile,addr szFile,MB_OK
invoke CreateFile,addr szFile,GENERIC_WRITE,FILE_SHARE_READ,\
NULL,Create_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL
mov @hFile,eax
invoke WriteFile,@hFile,@lpRes,@dwResSize,addr @dwTemp,NULL
invoke CloseHandle,@hFile
;====================================================
mov @stMCIOpen.lpstrDeviceType,offset szDevice
mov @stMCIOpen.lpstrElementName,offset szFile
invoke mciSendCommand,0,MCI_OPEN,MCI_OPEN_TYPE or MCI_OPEN_ELEMENT,addr @stMCIOpen
mov eax,@stMCIOpen.wDeviceID
mov hDevice,eax
mov eax,hWinMain
mov @stMCIPlay.dwCallback,eax
invoke mciSendCommand,hDevice,MCI_PLAY,MCI_NOTIFY,addr @stMCIPlay
;====================================================
ret
_PlayMID endp
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
_CloseMID proc
local @stMCIStop:MCI_GENERIC_PARMS
mov eax,hWinMain
mov @stMCIStop.dwCallback,eax
invoke mciSendCommand,hDevice,MCI_STOP,MCI_NOTIFY,addr @stMCIStop
invoke mciSendCommand,hDevice,MCI_CLOSE,MCI_NOTIFY,addr @stMCIStop
invoke DeleteFile,addr szFile
ret
_CloseMID endp
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
_ProcDlgMain proc uses ebx edi esi hWnd,wMsg,wParam,lParam
mov eax,wMsg
.if eax == WM_CLOSE
invoke _CloseMID
invoke EndDialog,hWnd,NULL
.elseif eax == WM_INITDIALOG
mov eax,hWnd
mov hWinMain,eax
invoke LoadIcon,hInstance,IDI_ICON1
invoke SendMessage,hWnd,WM_SETICON,ICON_BIG,eax
invoke _PlayMID
.elseif eax == WM_COMMAND
.else
mov eax,FALSE
ret
.endif
mov eax,TRUE
ret
_ProcDlgMain endp
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
start:
invoke GetModuleHandle,NULL
mov hInstance,eax
invoke DialogBoxParam,hInstance,IDD_DIALOG1,NULL,offset _ProcDlgMain,NULL
invoke ExitProcess,NULL
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
end start