如何使一个背景窗口图像幻灯片和无限的音乐循环播放的安装程序?(How to make install

2019-07-19 01:02发布

我想在我的安装程序:

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

  • 在背景上的窗口(如旧设备所使用与图像以填充屏幕和仅示出了安装窗口),与该背景画面上的幻灯片

如何做到这一点的InnoSetup?

Answer 1:

如果你想拥有与无限音乐曲目播放一个背景图像幻灯片一个安装程序,你可以做如下列:

  • 获取近期的版本InnoCallback库幻灯片定时器实现
  • 音乐播放得到的如最新副本Inno Media Player对Unicode Inno Setup的

写类似下面的脚本,或者download the complete project ,其中包括在未来的脚本代码中使用的所有必要的文件。 所以,你需要做的唯一的事情,是建立在它最近的Unicode版本Inno Setup的的。

请注意,汇创媒体播放器是一个Unicode库,所以你只能用Inno Setup的一个Unicode版本使用它,而不是用ANSI的! 没有为Inno Setup的ANSI的版本不支持...!

[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;

更多资源:

  • How to make a slideshow in InnoSetup ?
  • How to play a sound during InnoSetup installation process ?


Answer 2:

创建背景的特点:

你有没有尝试图形安装程序 ( http://www.graphical-installer.com )?

这是一个专业的Inno Setup的扩展专门为这个(创建很酷的安装与背景),所以建立这样的安装是几分钟的事情(没有编码是必需的)。



文章来源: How to make installer with a background window image slideshow and infinite music loop playback?
标签: inno-setup