背景:习惯于用borland公司的产品,虽然他的IDE产品要被卖掉了 ,写了一个注册机,想个性化一点,加入一首好听的音乐,把google翻遍了,却没发现有人将xm整入到程序中的,一大片一大片的都是vc,masm,很郁闷,睁着眼一夜没睡,一大早找到了解决方法
步骤:1。去SourceForge.net下载ufmod for win32,地址:http://sourceforge.net/projects/ufmod
2。解压缩后到ufmodlib 目录中,修改makeomf.bat中的内容
如下:
@echo off
rem Select compiler: TASM, MASM or NASM
rem (Choose TASM or NASM for Delphi compatibility)
SET ASM=NASM
rem Select output platform: WINMM or DIRECTSOUND
SET UFMOD_OUTPUT=WINMM
rem Select mixing rate: 22050, 44100 or 48000 (22.05 KHz, 44.1 KHz or 48 KHz)
SET UFMOD_MIXRATE=44100
rem Select filenames encoding (when using XM_FILE flag): ANSI or UNICODE
SET UFMOD_UFS=ANSI
SET OBJ=ufmod.obj tasm32 /mx /m4 /zn /q /d%UFMOD_OUTPUT%=1 /df%UFMOD_MIXRATE%=1 /d%UFMOD_UFS%=1 masm.asm, %OBJ%
pause
@echo on
cls
保存,运行,得到ufmod.obj
3。控制台当前目录下:tlib ufmod.lib +ufmod.obj 得到ufmod.lib
4.到visual_c目录下找到winmm\ufmod.h文件,修改一个函数:
HWAVEOUT* __stdcall uFMOD_PlaySong(void*, void*, int); --〉修改成:
void* __stdcall uFMOD_PlaySong(LPVOID lpXM, DWORD param,DWORD fdwSong);
保存。
5。将以上 ufmod.lib 和 ufmod.h 文件复制到你自己的程序目录下,工程中添加ufmod.lib,头文件引用 ufmod.h ,调用函数uFMOD_PlaySong,嘿嘿,搞定!
函数uFMOD_PlaySong 的调用方法:
(1)内存中:
char xm []={0x45,0x78,0x74,0x65,0x6E,0x64,0x65,0x64,0x20,0x4D,0x6F,0x64,0x75,0x6C,0x65,0x3A,
0x20,0x73,0x6F,0x66,0x74,0x20,0x6D,0x61,0x6E,0x69,0x61,0x63,0x2D,0x6D,0x69,0x6E,
0x69,0x6D,0x61,0x6C,0x00,0x1A,0x46,0x61,0x73,0x74,0x54,0x72,0x61,0x63,0x6B,0x65,
0x72,0x20,0x76,0x32,0x2E,0x30,0x30,0x20,0x20,0x20,0x04,0x01,0x14,0x01,0x00,0x00,
0x20,0x00,0x00,0x00,0x02,0x00,0x0D,0x00,0x01,0x00,0x01,0x00,0x0A,0x00,0x91,0x00,
0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,
0x08,0x09,0x0A,0x0B,0x08,0x09,0x0C,0x0B,0x08,0x09,0x0A,0x0B,0x08,0x09,0x0C,0x0B,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x09,0x00,0x00,0x00,0x00,0x04,0x00,0x15,0x00,0x83,0x16,0x01,0x80,0x80,0x9B,0x2E,
0x01,0x0E,0x60,0x80,0x9B,0x3A,0x01,0x0E,0x62,0x81,0x61,0x83,0x35,0x01,0x09,0x00,
0x00,0x00,0x00,0x04,0x00,0x15,0x00,0x83,0x16,0x01,0x80,0x80,0x9B,0x2E,0x01,0x0E,
0x60,0x80,0x9B,0x35,0x01,0x0E,0x62,0x81,0x61,0x83,0x38,0x01,0x09,0x00,0x00,0x00,
0x00,0x04,0x00,0x14,0x00,0x83,0x16,0x01,0x80,0x80,0x9B,0x2E,0x01,0x0E,0x60,0x80,
0x9B,0x38,0x01,0x0E,0x62,0x80,0x83,0x33,0x01,0x09,0x00,0x00,0x00,0x00,0x06,0x00,
0x1F,0x00,0x83,0x16,0x01,0x80,0x80,0x9B,0x2E,0x01,0x0E,0x60,0x80,0x9B,0x33,0x01,
0x0E,0x61,0x81,0x61,0x83,0x35,0x01,0x83,0x0D,0x01,0x83,0x36,0x01,0x80,0x83,0x36,
0x01,0x09,0x00,0x00,0x00,0x00,0x04,0x00,0x15,0x00,0x83,0x0F,0x01,0x80,0x80,0x9B,
0x2E,0x01,0x0E,0x60,0x80,0x9B,0x36,0x01,0x0E,0x62,0x81,0x61,0x83,0x33,0x01,0x09,
0x00,0x00,0x00,0x00,0x06,0x00,0x1F,0x00,0x83,0x0F,0x01,0x80,0x80,0x9B,0x2E,0x01,
0x0E,0x60,0x80,0x9B,0x33,0x01,0x0E,0x61,0x81,0x61,0x83,0x2E,0x01,0x83,0x12,0x01,
0x83,0x33,0x01,0x80,0x83,0x35,0x01,0x09,0x00,0x00,0x00,0x00,0x06,0x00,0x1F,0x00,
0x83,0x16,0x01,0x80,0x80,0x9B,0x2E,0x01,0x0E,0x60,0x80,0x9B,0x35,0x01,0x0E,0x61,
0x81,0x61,0x83,0x2E,0x01,0x83,0x0D,0x01,0x83,0x31,0x01,0x80,0x83,0x2E,0x01,0x09,
0x00,0x00,0x00,0x00,0x08,0x00,0x24,0x00,0x83,0x12,0x01,0x98,0x0A,0x01,0x83,0x19,
0x01,0x88,0x0A,0x83,0x1E,0x01,0x81,0x61,0x83,0x12,0x01,0x80,0x83,0x14,0x01,0x80,
0x83,0x1B,0x01,0x80,0x83,0x20,0x01,0x80,0x83,0x14,0x01,0x80,0x09,0x00,0x00,0x00,
0x00,0x08,0x00,0x25,0x00,0x83,0x12,0x01,0x81,0x61,0x83,0x19,0x01,0x80,0x83,0x1E,
0x01,0x80,0x83,0x12,0x01,0x80,0x83,0x19,0x01,0x83,0x31,0x01,0x83,0x1E,0x01,0x80,
0x83,0x12,0x01,0x83,0x31,0x01,0x83,0x19,0x01,0x80,0x09,0x00,0x00,0x00,0x00,0x08,
0x00,0x28,0x00,0x83,0x14,0x01,0x83,0x33,0x01,0x83,0x1B,0x01,0x80,0x83,0x20,0x01,
0x83,0x31,0x01,0x83,0x14,0x01,0x80,0x83,0x1B,0x01,0x83,0x30,0x01,0x83,0x20,0x01,
0x80,0x83,0x14,0x01,0x83,0x31,0x01,0x83,0x1B,0x01,0x80,0x09,0x00,0x00,0x00,0x00,
0x08,0x00,0x2A,0x00,0x83,0x16,0x01,0x83,0x30,0x01,0x83,0x1D,0x01,0x83,0x31,0x01,
0x83,0x22,0x01,0x83,0x35,0x01,0x83,0x16,0x01,0x98,0x0A,0x01,0x83,0x1D,0x01,0x88,
0x0A,0x83,0x22,0x01,0x81,0x61,0x83,0x16,0x01,0x80,0x83,0x1D,0x01,0x80,0x09,0x00,
0x00,0x00,0x00,0x08,0x00,0x20,0x00,0x83,0x16,0x01,0x80,0x83,0x1D,0x01,0x80,0x83,
0x22,0x01,0x80,0x83,0x16,0x01,0x80,0x83,0x18,0x01,0x80,0x83,0x1D,0x01,0x80,0x83,
0x11,0x01,0x80,0x83,0x18,0x01,0x80,0x09,0x00,0x00,0x00,0x00,0x08,0x00,0x2A,0x00,
0x83,0x16,0x01,0x83,0x30,0x01,0x83,0x1D,0x01,0x83,0x31,0x01,0x83,0x19,0x01,0x83,
0x2E,0x01,0x83,0x16,0x01,0x98,0x0A,0x01,0x83,0x1D,0x01,0x88,0x0A,0x83,0x19,0x01,
0x81,0x61,0x83,0x16,0x01,0x80,0x83,0x1D,0x01,0x80,0x07,0x01,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x27,0x01,0x00,0x28,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x00,0x08,
0x00,0x2C,0x00,0x0E,0x00,0x08,0x00,0x18,0x00,0x16,0x00,0x20,0x00,0x08,0x00,0x2D,
0x00,0x0D,0x00,0x32,0x00,0x04,0x00,0x3C,0x00,0x07,0x00,0x44,0x00,0x04,0x00,0x5A,
0x00,0x00,0x00,0x64,0x00,0x00,0x00,0x6E,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x0A,
0x00,0x28,0x00,0x1E,0x00,0x18,0x00,0x32,0x00,0x20,0x00,0x3C,0x00,0x20,0x00,0x46,
0x00,0x20,0x00,0x50,0x00,0x20,0x00,0x5A,0x00,0x20,0x00,0x64,0x00,0x20,0x00,0x6E,
0x00,0x20,0x00,0x78,0x00,0x20,0x00,0x82,0x00,0x20,0x00,0x09,0x06,0x01,0x02,0x04,
0x02,0x03,0x05,0x01,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x0C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0C,0x00,0x00,0x00,0x40,0x00,0x01,
0x80,0xF9,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xBF,0x00,0xC3,0x00,0x0A,0x00,0x57,
0x00,0x6E,0x00,0x23,0x00,0x58,0x54,0x50,0x4D,0x2E,0x2E,0x52,0x56,0x02,0x00,0x00,
0x00,0x2E,0x50,0x69,0x4D,0x01,0x00,0x00,0x2E,0x2E,0x43,0x4D,0x01,0x00,0x00,0x2E,
0x2E,0x50,0x4D,0x01,0x00,0x27,0x2E,0x2E,0x42,0x4D,0x02,0x00,0x00,0x00,0x2E,0x2E,
0x2E,0x50,0x04,0x00,0x80,0x00,0x00,0x00,0x2E,0x2E,0x56,0x47,0x04,0x00,0x40,0x00,
0x00,0x00,0x2E,0x2E,0x4F,0x46,0x04,0x00,0x80,0x00,0x00,0x00,0x2E,0x2E,0x2E,0x52,
0x04,0x00,0x05,0x00,0x00,0x00,0x2E,0x2E,0x53,0x43,0x01,0x00,0x00,0x2E,0x2E,0x53,
0x52,0x01,0x00,0x00,0x2E,0x2E,0x4D,0x46,0x01,0x00,0xFF,0x53,0x54,0x50,0x4D,0x2E,
0x2E,0x54,0x44,0x04,0x00,0x91,0x00,0x00,0x00,0x2E,0x42,0x50,0x52,0x04,0x00,0x04,
0x00,0x00,0x00,0x2E,0x4D,0x50,0x52,0x04,0x00,0x10,0x00,0x00,0x00,0x2E,0x2E,0x2E,
0x43,0x04,0x00,0x02,0x00,0x00,0x00,0x2E,0x2E,0x4D,0x54,0x01,0x00,0x00,0x2E,0x4D,
0x4D,0x50,0x01,0x00,0x02,0x2E,0x56,0x57,0x43,0x04,0x00,0x00,0x00,0x00,0x00,0x56,
0x57,0x53,0x4C,0x04,0x00,0x28,0x02,0x17,0x01,0x2E,0x41,0x50,0x53,0x04,0x00,0x64,
0x00,0x00,0x00,0x56,0x54,0x53,0x56,0x04,0x00,0x64,0x00,0x00,0x00,0x2E,0x56,0x47,
0x44,0x04,0x00,0x00,0x01,0x00,0x00};
调用:uFMOD_PlaySong(&xm,sizeof(xm),XM_MEMORY);
(2)文件中:
调用:uFMOD_PlaySong("../1.xm",0,XM_FILE); 附件中是已经修改好的 ufmod.lib和ufmod.h,加入程序中可以直接使用
[招生]科锐逆向工程师培训(2024年11月15日实地,远程教学同时开班, 第51期)
上传的附件: