gpt4 book ai didi

audio - 如何在Inno Setup(返回+下一步+取消)中单击按钮时自定义单击声音?

转载 作者:行者123 更新时间:2023-12-03 00:40:09 26 4
gpt4 key购买 nike

在Inno设置中如何使按钮单击声音?

我的意思是“返回”,“下一步”和“取消”不同。

我知道可能会有一些问题和答案,但是我是这个网站的新手,我需要一些帮助。

提前致谢...

最佳答案

您可以使用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;

关于audio - 如何在Inno Setup(返回+下一步+取消)中单击按钮时自定义单击声音?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35411415/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com