Inno Setup Pascal/delphi脚本代码集锦2

闪屏、背景音乐、URL三合一[Inno Setup 脚本]

Code代码段,具体如下:

[Code]
procedure URLLabelOnClick(Sender: TObject);
var
ErrorCode: Integer;

begin
ShellExec('open', ' http://bbs.exetool.com ', '', '', SW_SHOWNORMAL, ewNoWait, ErrorCode);
end;                       (链接网址)

function mciSendString(lpszCommand: String; lpszReturnString: Integer; cchReturnLength: Integer; hwndCallback: Integer): Integer;
external 'mciSendStringA@winmm.dll stdcall';

procedure InitializeWizard();
var
SplashImage: TBitmapImage;
SplashForm: TForm;
SplashFileName: String;
I : Integer;
URLLabel: TNewStaticText;
CancelButton: TButton;

begin

WizardForm.WELCOMELABEL1.Font.Color:= clRed;
WizardForm.WELCOMELABEL1.Font.Name:= '宋体';
WizardForm.WELCOMELABEL1.Font.Size:= 11;
CancelButton := WizardForm.CancelButton;
ExtractTemporaryFile(ExtractFileName(ExpandConstant('{tmp}/dream.mid')));
mciSendString(ExpandConstant('play {tmp}/dream.mid'),0,0,0);
                                                   (背景音乐)

URLLabel := TNewStaticText.Create(WizardForm);
URLLabel.Top := CancelButton.Top;
URLLabel.Left := WizardForm.Width - CancelButton.Left - CancelButton.Width;
URLLabel.Caption := '  软件本地化团队';         (左下角的链接文字)
URLLabel.Font.Color := clBlue;
URLLabel.Cursor := crHand;
URLLabel.OnClick := @URLLabelOnClick;
URLLabel.Parent := WizardForm;
SplashFileName := ExpandConstant('{tmp}/RAR_Splash.bmp');
ExtractTemporaryFile(ExtractFileName(SplashFileName));

SplashForm := TForm.create(nil);
with SplashForm do
  begin
  BorderStyle := bsNone;
  Position := poScreenCenter;
  ClientWidth := 354;     (闪屏宽)
  ClientHeight := 180;         (闪屏宽)
  end;

SplashImage := TBitmapImage.Create(SplashForm);
with SplashImage do
  begin
  Bitmap.LoadFromFile(SplashFileName);
  Stretch := true;
  Align := alClient;
  Parent := SplashForm;
  end;

with SplashForm do
  begin
  Show;
  for I := 1 to 2 do
    begin
    Repaint;
    Sleep(1000);
    end;
  Close;
  Free;
  end;
  end;

 

两个音乐的脚本供参考:

midi格式的背景音乐


Quote:

procedure URLLabelOnClick(Sender: TObject);
var
ErrorCode: Integer;
begin
ShellExec('open', 'http://bbs.exetool.com', '', '', SW_SHOWNORMAL, ewNoWait, ErrorCode);
end;

function mciSendString(lpszCommand: String; lpszReturnString: Integer; cchReturnLength: Integer; hwndCallback: Integer): Integer;
external 'mciSendStringA@winmm.dll stdcall';

procedure InitializeWizard();
var
URLLabel: TNewStaticText;
CancelButton: TButton;
begin

WizardForm.WELCOMELABEL1.Font.Color:= clRed;
WizardForm.WELCOMELABEL1.Font.Name:= '宋体';
WizardForm.WELCOMELABEL1.Font.Size:= 11;

CancelButton := WizardForm.CancelButton;

ExtractTemporaryFile(ExtractFileName(ExpandConstant('{tmp}/dream.mid')));
mciSendString(ExpandConstant('play {tmp}/dream.mid'),0,0,0);

URLLabel := TNewStaticText.Create(WizardForm);
URLLabel.Top := CancelButton.Top;
URLLabel.Left := WizardForm.Width - CancelButton.Left - CancelButton.Width;
URLLabel.Caption := '  访问SLT论坛';
URLLabel.Font.Color := clRed;
URLLabel.Cursor := crHand;
URLLabel.OnClick := @URLLabelOnClick;
URLLabel.Parent := WizardForm;
end;

 

Mp3格式的背景音乐(循环播放)


Quote:
[code]
function mciSendString(lpstrCommand, lpstrReturnString: PChar; uReturnLength: UINT; hWndCallback: HWND): Integer;
external 'mciSendStringA@winmm.dll stdcall';

procedure InitializeWizard();
var
s: string;
begin
  WizardForm.WELCOMELABEL1.Font.Color:= clRed;
  ExtractTemporaryFile(ExtractFileName(ExpandConstant('{tmp}/bird.mp3')));
  mciSendString(ExpandConstant('OPEN {tmp}/bird.mp3 TYPE MPEGVIDEO ALIAS BGMUSIC'),s,255,0);
  mciSendString(ExpandConstant('PLAY BGMUSIC REPEAT'),s,255,0);
end;

其他

[Setup]
AppName=My Program
AppVerName=My Program version 1.5
DefaultDirName={pf}/My Program
 
[Files]
Source: Files/*; DestDir: {app}
 
[Code]
const
  NeedSize = 20; //Прописать, сколько мегабайт необходимо
  
  DRIVE_UNKNOWN = 0;
  DRIVE_NO_ROOT_DIR = 1;
  DRIVE_REMOVEABLE = 2;
  DRIVE_FIXED = 3;
  DRIVE_REMOTE = 4;
  DRIVE_CDROM = 5;
  DRIVE_RAMDISK = 6;
  
function GetLogicalDrives: DWORD;
external 'GetLogicalDrives@kernel32.dll stdcall';
 
function GetDriveType(nDrive: String): Longint;
external 'GetDriveTypeA@kernel32.dll stdcall';
 
procedure InitializeWizard();
var
  Path: String;
  FreeMB, TotalMB: Cardinal;
  ListBox: TListBox;
  drives: DWORD;
  i: integer;
begin
  ListBox:= TListBox.Create(WizardForm);
  ListBox.Top:= 120;
  ListBox.Width:= 300;
  ListBox.Height:= ScaleY(90);
  ListBox.Parent:= WizardForm.SelectDirPage;
  
  drives:= GetLogicalDrives();
  for i:= 0 to 31 do
     begin
        if (drives and (1 shl i)) > 0 then
            begin
              Path:= chr(ord('A')+i)+':';
              if GetDriveType(Path) = DRIVE_FIXED then
                begin
                  GetSpaceOnDisk(Path, True, FreeMB, TotalMB);
                  ListBox.Items.Add(Path + ' - Всего: ' + IntToStr(TotalMB) +
                                 'Мб - Свободно: ' + IntToStr(FreeMB) + 'Мб');
                end;
            end;
     end;
end;
 
function NextButtonClick(CurPageID: Integer): Boolean;
var
  Path: String;
  FreeMB, TotalMB: Cardinal;
begin
  Result:= True;
  if CurPageID = wpSelectDir then
    begin
      Path:= ExtractFileDrive(WizardForm.DirEdit.Text);
      GetSpaceOnDisk(Path, True, FreeMB, TotalMB);
      if FreeMB < NeedSize then
        begin
          MsgBox('Недостаточно места на диске!', mbInformation, MB_OK)
          Result:= False;
        end;
    end;
end;
 
Добавлено:
[Files]
Source: C:/Image.bmp; DestDir: {tmp}; Flags: dontcopy

[Code]
var
  Page: TWizardPage;
  BitmapImage: TBitmapImage;
 
procedure InitializeWizard();
begin
 ExtractTemporaryFile('Image.bmp')
 Page:=CreateCustomPage(wpInstalling, 'Картинка', 'Тут что-то еще написать можно!')
 BitmapImage:=TBitmapImage.Create(Page)
 with BitmapImage do begin
   Left:=0
   Top:=0
   Width:=417
   Height:=237
   Parent:=Page.Surface
   Bitmap.LoadFromFile(ExpandConstant('{tmp}')+'/Image.bmp')
 end
end;
 
На новой странице я не смог это сделать но можно сделать на готовой странице wpInfoAfter и в инсталлятор прийдётся включать пустой текстовый файл но отображатся он не будет.
[Setup]
InfoAfterFile=C:/text.txt
 
[Files]
Source: C:/Image.bmp; DestDir: {tmp}; Flags: dontcopy
 
[Code]
var
  BitmapImage: TBitmapImage;
 
procedure CurPageChanged(CurPageID: Integer);
begin
If CurPageID=wpInfoAfter then
 begin
 ExtractTemporaryFile('Image.bmp')
 BitmapImage:=TBitmapImage.Create(WizardForm)
 with BitmapImage do begin
   Left:=0
   Top:=0
   Width:=497
   Height:=313
   Parent:=WizardForm.InfoAfterPage
   Bitmap.LoadFromFile(ExpandConstant('{tmp}')+'/Image.bmp')
 end
   WizardForm.InnerNotebook.Top:=0
   WizardForm.InnerNotebook.Left:=0
   WizardForm.InnerNotebook.Width:=497
   WizardForm.InnerNotebook.Height:=313
   WizardForm.MainPanel.Visible:=False
   WizardForm.Bevel1.Visible:=False
   WizardForm.InfoAfterMemo.Visible:=False
   WizardForm.InfoAfterClickLabel.Visible:=False
end
end; 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值