1

我想在我的安装程序中有:

  • 安装过程中无限循环播放音乐

  • 背景上的一个窗口(就像以前的安装一样,用图像填充屏幕并只显示安装窗口),在该背景窗口上带有幻灯片

如何在 InnoSetup 中执行此操作?

4

2 回答 2

6

如果您想要安装一个带有无限音乐曲目播放的背景图像幻灯片的安装程序,您可以执行以下操作:

  • InnoCallback获取用于幻灯片计时器实现的库的最新版本
  • Inno Media Player用于音乐播放获取例如Unicode Inno Setup的最新副本

编写一个类似于以下或 的脚本download the complete project,其中包括下一个脚本代码中使用的所有必要文件。因此,您唯一需要做的就是在最新版本的 Unicode Inno Setup 中构建它。

请注意,Inno Media Player 是一个 Unicode 库,因此您只能将它与 Inno Setup 的 Unicode 版本一起使用,而不能与 ANSI 版本一起使用!不支持 ANSI 版本的 Inno Setup...!

[Setup]
AppName=My Program
AppVersion=1.5
DefaultDirName={pf}\My Program
OutputDir=userdocs:Inno Setup Examples Output
BackColor=clLime
BackColor2=clYellow
WindowVisible=yes

[Files]
Source: "Image1.bmp"; Flags: dontcopy
Source: "Image2.bmp"; Flags: dontcopy
Source: "AudioFile.mp3"; Flags: dontcopy
Source: "MediaPlayer.dll"; Flags: dontcopy
Source: "InnoCallback.dll"; Flags: dontcopy

[Code]
var
  TimerID: Integer;
  SlideID: Integer;
  BackImage: TBitmapImage;
const
  EC_COMPLETE = $01;
type
  TTimerProc = procedure(Wnd: HWND; Msg: UINT; TimerID: UINT_PTR; 
    SysTime: DWORD);
  TDirectShowEventProc = procedure(EventCode, Param1, Param2: Integer);

function WrapTimerProc(Callback: TTimerProc; ParamCount: Integer): LongWord;
  external 'wrapcallback@files:InnoCallback.dll stdcall';    
function SetTimer(hWnd: HWND; nIDEvent, uElapse: UINT;
  lpTimerFunc: UINT): UINT; external 'SetTimer@user32.dll stdcall';
function KillTimer(hWnd: HWND; uIDEvent: UINT): BOOL; 
  external 'KillTimer@user32.dll stdcall'; 

function DSGetLastError(var ErrorText: WideString): HRESULT;
  external 'DSGetLastError@files:mediaplayer.dll stdcall';
function DSPlayMediaFile: Boolean;
  external 'DSPlayMediaFile@files:mediaplayer.dll stdcall';
function DSStopMediaPlay: Boolean;
  external 'DSStopMediaPlay@files:mediaplayer.dll stdcall';
function DSSetVolume(Value: LongInt): Boolean;
  external 'DSSetVolume@files:mediaplayer.dll stdcall';
function DSInitializeAudioFile(FileName: WideString; 
  CallbackProc: TDirectShowEventProc): Boolean; 
  external 'DSInitializeAudioFile@files:mediaplayer.dll stdcall';

procedure OnMediaPlayerEvent(EventCode, Param1, Param2: Integer); 
begin
  if EventCode = EC_COMPLETE then
  begin
    if DSInitializeAudioFile(ExpandConstant('{tmp}\AudioFile.mp3'), 
      @OnMediaPlayerEvent) then
    begin
      DSSetVolume(-2500);
      DSPlayMediaFile;
    end;
  end;
end;

procedure OnSlideTimer(Wnd: HWND; Msg: UINT; TimerID: UINT_PTR; 
  SysTime: DWORD);
begin
  case SlideID of 
    0: SlideID := 1;
    1: SlideID := 0;
  end;
  BackImage.Bitmap.LoadFromFile(
    ExpandConstant('{tmp}\Image' + IntToStr(SlideID + 1) + '.bmp'));
end;

procedure StartSlideTimer;
var
  TimerCallback: LongWord;
begin
  TimerCallback := WrapTimerProc(@OnSlideTimer, 4);
  { third parameter here is the timer's timeout value in milliseconds }
  TimerID := SetTimer(0, 0, 5000, TimerCallback);
end;

procedure KillSlideTimer;
begin
  if TimerID <> 0 then 
  begin
    if KillTimer(0, TimerID) then
      TimerID := 0;
  end;
end;

procedure InitializeWizard;
var
  ErrorCode: HRESULT;
  ErrorText: WideString;   
begin
  TimerID := 0;
  SlideID := 0;
  ExtractTemporaryFile('Image1.bmp');
  ExtractTemporaryFile('Image2.bmp');
  BackImage := TBitmapImage.Create(MainForm);
  BackImage.Parent := MainForm;
  BackImage.Top := 70;
  BackImage.Left := 10;  
  BackImage.AutoSize := True;
  BackImage.Bitmap.LoadFromFile(ExpandConstant('{tmp}\Image1.bmp'));
  StartSlideTimer;

  ExtractTemporaryFile('AudioFile.mp3');
  if DSInitializeAudioFile(ExpandConstant('{tmp}\AudioFile.mp3'), 
    @OnMediaPlayerEvent) then
  begin
    DSSetVolume(-2500);
    DSPlayMediaFile;
  end
  else
  begin
    ErrorCode := DSGetLastError(ErrorText);
    MsgBox('TDirectShowPlayer error: ' + IntToStr(ErrorCode) + '; ' + 
      ErrorText, mbError, MB_OK);
  end;
end;

procedure DeinitializeSetup;
begin
  KillSlideTimer;
  DSStopMediaPlay;
end;

更多资源:

于 2013-01-31T00:57:14.220 回答
0

创建背景功能:

您是否尝试过图形安装程序( http://www.graphical-installer.com )?

这是一个专业的 Inno Setup 扩展(创建具有背景的酷炫安装程序),因此创建这样的安装程序只需几分钟(无需编码)。

于 2016-09-22T08:24:11.213 回答