[Code]
Type
HSAMPLE = DWORD;
HCHANNEL = DWORD;
var
MusicSwitchLabel1: TNewStaticText;
sample: HSAMPLE;
channel: HCHANNEL;
// 以下是所调用的插件函数
function BASS_Init(device: Integer; freq, flags: DWORD; win: HWND; clsid: string): Boolean;
external 'BASS_Init@files:BASS.dll stdcall delayload';
procedure BASS_Free();
external 'BASS_Free@files:BASS.dll stdcall delayload';
function BASS_SampleLoad(mem: BOOL; f: PAnsiChar; offset, length, max, flags: DWORD): HSAMPLE;
external 'BASS_SampleLoad@files:BASS.dll stdcall delayload';
function BASS_ChannelPlay(handle: DWORD; restart: BOOL): BOOL;
external 'BASS_ChannelPlay@files:BASS.dll stdcall delayload';
function BASS_ChannelPause(handle: DWORD): BOOL;
external 'BASS_ChannelPause@files:BASS.dll stdcall delayload';
function BASS_SampleGetChannel(handle: HSAMPLE; onlynew: BOOL): HCHANNEL;
external 'BASS_SampleGetChannel@files:BASS.dll stdcall delayload';
procedure callplug(parentwnd: Integer; pluginname,funcname,param1,param2,param3,param4,param5,param6,param7,param8,param9,param10: PAnsiChar);
external 'callplug@files:callnsis.dll stdcall delayload';
// 以下是点击“关于”按钮后的响应函数
procedure AboutButtonOnClick(Sender: TObject);
begin
MsgBox('这是你的信息。'#13#10'这是你的信息的第二行。', mbInformation, MB_OK);
end;
// 以下是点击“关闭音乐”按钮后的响应函数
procedure MusicSwitchLabel1OnClick(Sender: TObject);
begin
if MusicSwitchLabel1.Caption = '关闭音乐' then
begin
BASS_ChannelPause(channel);
MusicSwitchLabel1.Caption := '打开音乐';
end
else
begin
BASS_ChannelPlay(channel, false);
MusicSwitchLabel1.Caption := '关闭音乐';
end;
end;
// 安装向导初始化函数
procedure InitializeWizard();
var
AboutButton: TButton;
BGMusicFile, SplashFile: string;
begin
// 创建“关于”按钮
AboutButton := TButton.Create(WizardForm);
AboutButton.Left := WizardForm.ClientWidth - WizardForm.CancelButton.Left - WizardForm.CancelButton.Width;
AboutButton.Top := WizardForm.CancelButton.Top;
AboutButton.Width := WizardForm.CancelButton.Width;
AboutButton.Height := WizardForm.CancelButton.Height;
AboutButton.Caption := '关于(&A)...';
AboutButton.OnClick := @AboutButtonOnClick;
AboutButton.Parent := WizardForm;
// 创建文字标签作为“打开音乐”或“关闭音乐”按钮
MusicSwitchLabel1 := TNewStaticText.Create(WizardForm);
MusicSwitchLabel1.Left := AboutButton.Left + ScaleX(110);
MusicSwitchLabel1.Top := WizardForm.CancelButton.Top + ScaleY(7);
MusicSwitchLabel1.Width := ScaleX(50);
MusicSwitchLabel1.Height := ScaleY(12);
MusicSwitchLabel1.Font.Color := clBlue;
MusicSwitchLabel1.Font.Style := [fsUnderline];
MusicSwitchLabel1.Cursor := crHand;
MusicSwitchLabel1.Caption := '关闭音乐';
MusicSwitchLabel1.OnClick := @MusicSwitchLabel1OnClick;
MusicSwitchLabel1.Parent := WizardForm;
// 释放临时文件
ExtractTemporaryFile('BASS.dll');
ExtractTemporaryFile('CallNSIS.DLL');
ExtractTemporaryFile('NewAdvSplash.DLL');
ExtractTemporaryFile('mymusic.mp3');
ExtractTemporaryFile('splash.gif');
BGMusicFile := ExpandConstant('{tmp}\mymusic.mp3');
SplashFile := ExpandConstant('{tmp}\splash.gif');
// 播放背景音乐
if not BASS_Init(-1,44100,0,0,'') then
BASS_Free;
sample := BASS_SampleLoad(false, PAnsiChar(BGMusicFile), 0, 0, 1, 4);
if sample<>0 then
begin
channel:= BASS_SampleGetChannel(sample, false);
BASS_ChannelPlay(channel, true);
end;
// 闪屏:显示时间 1600、淡入 800、淡出 500、透明颜色 -2 (表示 gif 图像本身透明)
callplug(0,ExpandConstant('{tmp}\NewAdvSplash.dll'),'show','1600','800','500','-2',SplashFile,'','','','','');
// 以下是安装向导初始化函数的其它代码
// 请自己加上
end;
// 以下是其它 CODE 段代码
// 请自己加上