如何在 Inno Setup 中单击按钮时自定义单击声音(返回 + 下一步 + 取消)?
How to have a custom click sound on button click in Inno Setup (Back + Next + Cancel)?
如何在 Inno setup 中设置按钮点击声音?
我的意思是 "Back"、"Next" 和 "Cancel".
我知道可能会有一些问题和答案,但我是这个网站的新手,我需要一些帮助。
提前致谢...
您可以使用Inno Media Player来播放声音。
参见问题Playing sound during an Inno Setup install。
要在点击按钮时触发声音,请使用如下代码:
[Files]
Source: "next.mp3"; Flags: dontcopy
Source: "back.mp3"; Flags: dontcopy
Source: "cancel.mp3"; Flags: dontcopy
Source: "MediaPlayer.dll"; Flags: dontcopy
[Code]
type
TDirectShowEventProc = procedure(EventCode, Param1, Param2: Integer);
function DSInitializeAudioFile(
FileName: string; CallbackProc: TDirectShowEventProc): Boolean;
external 'DSInitializeAudioFile@files:mediaplayer.dll stdcall';
function DSPlayMediaFile: Boolean;
external 'DSPlayMediaFile@files:mediaplayer.dll stdcall';
function DSStopMediaPlay: Boolean;
external 'DSStopMediaPlay@files:mediaplayer.dll stdcall';
function GetTickCount: DWORD;
external 'GetTickCount@kernel32.dll stdcall';
procedure DeinitializeSetup;
begin
DSStopMediaPlay;
end;
var
PageChanged: DWORD;
procedure CurPageChanged(CurPageID: Integer);
begin
PageChanged := GetTickCount;
end;
procedure DirectShowEvent(EventCode, Param1, Param2: Integer);
begin
{ dummy }
end;
procedure PlaySound(FileName: string);
begin
DSStopMediaPlay;
ExtractTemporaryFile(FileName);
if DSInitializeAudioFile(ExpandConstant('{tmp}\') + FileName, @DirectShowEvent) then
begin
DSPlayMediaFile;
end;
end;
function NextButtonClick(CurPageID: Integer): Boolean;
begin
{ NextButtonClick is called even for skipped pages (like the Welcome page) and }
{ during silent installs. To detect that, we check if at least half }
{ second elapsed since the page was shown }
if GetTickCount - PageChanged > 500 then
begin
PlaySound('next.mp3');
end;
Result := True;
end;
function BackButtonClick(CurPageID: Integer): Boolean;
begin
PlaySound('back.mp3');
Result := True;
end;
procedure CancelButtonClick(CurPageID: Integer; var Cancel, Confirm: Boolean);
begin
PlaySound('cancel.mp3');
end;
如何在 Inno setup 中设置按钮点击声音?
我的意思是 "Back"、"Next" 和 "Cancel".
我知道可能会有一些问题和答案,但我是这个网站的新手,我需要一些帮助。
提前致谢...
您可以使用Inno Media Player来播放声音。
参见问题Playing sound during an Inno Setup install。
要在点击按钮时触发声音,请使用如下代码:
[Files]
Source: "next.mp3"; Flags: dontcopy
Source: "back.mp3"; Flags: dontcopy
Source: "cancel.mp3"; Flags: dontcopy
Source: "MediaPlayer.dll"; Flags: dontcopy
[Code]
type
TDirectShowEventProc = procedure(EventCode, Param1, Param2: Integer);
function DSInitializeAudioFile(
FileName: string; CallbackProc: TDirectShowEventProc): Boolean;
external 'DSInitializeAudioFile@files:mediaplayer.dll stdcall';
function DSPlayMediaFile: Boolean;
external 'DSPlayMediaFile@files:mediaplayer.dll stdcall';
function DSStopMediaPlay: Boolean;
external 'DSStopMediaPlay@files:mediaplayer.dll stdcall';
function GetTickCount: DWORD;
external 'GetTickCount@kernel32.dll stdcall';
procedure DeinitializeSetup;
begin
DSStopMediaPlay;
end;
var
PageChanged: DWORD;
procedure CurPageChanged(CurPageID: Integer);
begin
PageChanged := GetTickCount;
end;
procedure DirectShowEvent(EventCode, Param1, Param2: Integer);
begin
{ dummy }
end;
procedure PlaySound(FileName: string);
begin
DSStopMediaPlay;
ExtractTemporaryFile(FileName);
if DSInitializeAudioFile(ExpandConstant('{tmp}\') + FileName, @DirectShowEvent) then
begin
DSPlayMediaFile;
end;
end;
function NextButtonClick(CurPageID: Integer): Boolean;
begin
{ NextButtonClick is called even for skipped pages (like the Welcome page) and }
{ during silent installs. To detect that, we check if at least half }
{ second elapsed since the page was shown }
if GetTickCount - PageChanged > 500 then
begin
PlaySound('next.mp3');
end;
Result := True;
end;
function BackButtonClick(CurPageID: Integer): Boolean;
begin
PlaySound('back.mp3');
Result := True;
end;
procedure CancelButtonClick(CurPageID: Integer; var Cancel, Confirm: Boolean);
begin
PlaySound('cancel.mp3');
end;