[Inno]制作类似矮人工具箱的程序/设置系统启动时间工具

这里使用简单代码实现了,Inno对 系统工具箱的配置和安装,是起步的好材料

 

[Code]
var

AboutButton,CancelButton:TButton;
URLLabel: TNewStaticText;
BackgroundBitmapImage: TBitmapImage;
BackgroundBitmapText: TNewStaticText;
UserPage: TInputQueryWizardPage;
IniFile, OldString, NewString:string;
i,ResultCode: Integer;
IniFileLines: TArrayOfString;

function InitializeSetup(): boolean;
begin
  Result := true
  Exec(ExpandConstant('{sys}/attrib.exe'), '-r -s -h c:/boot.ini', ExpandConstant('{sys}'), SW_HIDE,
    ewnoWait, ResultCode)
  Result := MsgBox('安装须知:' #13#13 '如果您的系统为多系统,请在win2000,winXP,WIN2003下安装使用。', mbConfirmation, MB_YESNO) = idYes;
if inikeyExists('operating systems','c:/grldr','c:/boot.ini') then
  begin
Result := MsgBox('程序安装向导:' #13#13 '你已经安装过其他dos工具,选择<是>将升级为"XX备份恢复工具1.0"'#13#10'选择<否>保留现有dos工具箱并退出安装。' ,mbConfirmation, MB_YESNO) = idyes
  if Result = true then
  deltree (ExpandConstant('{sd}/boot'),true,true,true)
  if Result = False then
  MsgBox('程序安装向导:' #13#13 '您选择保留原有工具箱,现在将退出安装程序,再见。', mbInformation, MB_OK);
  end;
end;
procedure AboutButtonOnClick(Sender: TObject);
begin
MsgBox('本安装程序由“XXX”LQL制作' #13#13 '更多绿软请光临"XXX"', mbInformation, mb_Ok);
end;


procedure URLLabelOnClick(Sender: TObject);
var
ErrorCode: Integer;
begin
ShellExec('open', 'http://WWW.XXXX.COM', '', '', SW_SHOWNORMAL, ewNoWait, ErrorCode);
end;

procedure InitializeWizard();
begin
WizardForm.PAGENAMELABEL.Font.Color:= clRed;
WizardForm.PAGEDESCRIPTIONLABEL.Font.Color:= clBlue;
WizardForm.WELCOMELABEL1.Font.Color:= clpurple;
WizardForm.WELCOMELABEL2.Font.Color:= clolive;
WizardForm.PASSWORDLABEL.TabOrder := 0;
CancelButton := WizardForm.CancelButton;

AboutButton := TButton.Create(WizardForm);
AboutButton.Left := WizardForm.ClientWidth - CancelButton.Left - CancelButton.Width;
AboutButton.Top := CancelButton.Top;
AboutButton.Width := CancelButton.Width;
AboutButton.Height := CancelButton.Height;
AboutButton.Caption := '关于(A)...';
AboutButton.OnClick := @AboutButtonOnClick;
AboutButton.Parent := WizardForm;

URLLabel := TNewStaticText.Create(WizardForm);
URLLabel.Caption := 'XXXX 精简软件';
URLLabel.Cursor := crHand;
URLLabel.OnClick := @URLLabelOnClick;
URLLabel.Parent := WizardForm;
{ Alter Font *after* setting Parent so the correct defaults are inherited first }
URLLabel.Font.Style := URLLabel.Font.Style + [fsUnderline];
URLLabel.Font.Color := clBlue;
URLLabel.Top := AboutButton.Top + AboutButton.Height - URLLabel.Height - 2;
URLLabel.Left := AboutButton.Left + AboutButton.Width + ScaleX(20);

BackgroundBitmapImage := TBitmapImage.Create(MainForm);
BackgroundBitmapImage.Left := 50;
BackgroundBitmapImage.Top := 100;
BackgroundBitmapImage.AutoSize := True;
BackgroundBitmapImage.Bitmap := WizardForm.WizardBitmapImage.Bitmap;
BackgroundBitmapImage.Parent := MainForm;

BackgroundBitmapText :=  TNewStaticText.Create(MainForm);
BackgroundBitmapText.Left := BackgroundBitmapImage.Left;
BackgroundBitmapText.Top := BackgroundBitmapImage.Top + BackgroundBitmapImage.Height +  ScaleY(8);
BackgroundBitmapText.Caption := 'TBitmapImage';
BackgroundBitmapText.Parent := MainForm;
UserPage := CreateInputQueryPage(wppassword,
'个性启动设置', '请输入您设置的WINDOWS 启动菜单停留时间和XXXX备份恢复工具启动密码',
'在这里设置WINDOWS 启动菜单停留时间和51LITE 备份恢复启动密码。请自己牢记!!!!');
UserPage.Add('XXXX 工具箱启动密码(默认为空):', False);
UserPage.Add('windows 启动菜单停留时间(默认为8秒钟):', False);
UserPage.Values[0] := ''
UserPage.Values[1] := '8'

end;

procedure CurStepChanged(CurStep: TSetupStep);
begin

if CurStep = ssdone then
begin
   SetIniString('boot loader', 'timeout', UserPage.Values[1], 'c:/boot.ini');
   IniFile:='C:/boot/grub/menu.lst';
   begin
   OldString:='password ';
   NewString:= 'password '+UserPage.Values[0];
   LoadStringsFromFile(IniFile, IniFileLines);
   for i:= 0 to GetArrayLength(IniFileLines)-1 do
   if (Pos(OldString, IniFileLines) > 0) then
   StringChange(IniFileLines, OldString, NewString);
   SaveStringsToFile(IniFile, IniFileLines, False);
  end;
end;
end;
procedure DeinitializeSetup();

begin
Exec(ExpandConstant('{sys}/attrib.exe'), ' +s +h c:/boot.ini', ExpandConstant('{sys}'), SW_HIDE,
ewWaitUntilIdle, ResultCode)
  end;
function InitializeUninstall():boolean;
  begin
  Result := true
  Exec(ExpandConstant('{sys}/attrib.exe'), '-r -s -h c:/boot.ini', ExpandConstant('{sys}'),  SW_HIDE,
ewnoWait, ResultCode)

end;

procedure DeInitializeUninstall();

begin
  Exec(ExpandConstant('{sys}/attrib.exe'), ' +s +h c:/boot.ini', ExpandConstant('{sys}'), SW_HIDE,
  ewWaitUntilIdle, ResultCode)
end;

 

 

顺便附上一个相关小工具代码:

 
[Setup]
AppName=Boot V 1.5
AppVerName=Boot 1.5
DefaultDirName={tmp}
OutputBaseFilename=Boot
Uninstallable=no
DisableDirPage =yes
DisableProgramGroupPage=true
DisableReadyPage =yes
DisableFinishedPage =yes

[Messages]
SetupWindowTitle=Boot修改
ButtonCancel=退出
ButtonNext=修改
ExitSetupTitle=退出修改!
ExitSetupMessage=修改未完成 %n%n 点击“是”退出修改,点击“否”继续修改!

[INI]
Filename: {sd}/boot.ini; Section: boot loader; Key: timeout; String: {code:GetYourTimeOut}
Filename: {sd}/boot.ini; Section: operating systems; Key: {sd}/grldr; String: {code:GetYourName}; Flags: createkeyifdoesntexist uninsdeleteentry
[Code]
procedure CurPageChanged(CurPageID: Integer);
begin
  if CurPageID = wpWelcome then
    WizardForm.NextButton.OnClick(WizardForm)
    WizardForm.BorderIcons:= [biSystemMenu, biMinimize];
  if CurPageID = wpInstalling then
    WizardForm.Hide
  WizardForm.BackButton.Visible:= false;
end;
var
Page: TInputQueryWizardPage;
ValueYouEntered0: string;
ValueYouEntered1: string;
function GetYourTimeOut(Param: string): string;
begin
result:= ValueYouEntered0;
end;
function GetYourName(Param: string): string;
begin
result:= ValueYouEntered1;
MsgBox('修改成功!', mbInformation, MB_OK);
end;
procedure InitializeWizard();
var iCode: Integer;
begin
Exec('attrib.exe', '-r -h -s '+ExpandConstant('{sd}/boot.ini'), '', SW_HIDE, ewWaitUntilTerminated, iCode);
Page := CreateInputQueryPage(wpLicense, '系统启动菜单设置', '设置你的启动菜单', '请设置你的启动菜单,然后单击“修改”。');
Page.Add('操作系统列表等待时间(显示的为当前等待时间):', false);
Page.Add('操作系统列表启动项名称(显示的为当前PE启动项名称):', false);
if IniKeyExists('boot loader', 'timeout', ExpandConstant('{sd}/boot.ini')) then
Page.Values[0]:= GetIniString('boot loader', 'timeout', '', ExpandConstant('{sd}/boot.ini'));
if IniKeyExists('operating systems', ExpandConstant('{sd}/grldr'), ExpandConstant('{sd}/boot.ini')) then
Page.Values[1]:= GetIniString('operating systems',ExpandConstant('{sd}/grldr'), '', ExpandConstant('{sd}/boot.ini'));
end;
function NextButtonClick(CurPageID: Integer): Boolean;
begin
result:= true;
if CurPageID = Page.ID then
begin
  if (StrToIntDef(Page.Values[0],-1)<1) or (StrToIntDef(Page.Values[0],-1)>60) then
    begin
     MsgBox('请输入一个 1 与 60 之间的整数!', mbInformation, MB_OK);
     result:= false;
    end
  if Length(Page.Values[1])<1 then
    begin
     MsgBox('请输入启动项名称!', mbInformation, MB_OK);
     result:= false;
    end
else
ValueYouEntered0:= Page.Values[0];
ValueYouEntered1:= Page.Values[1];
end;
end;
procedure DeinitializeSetup();
var iCode: Integer;
begin
Exec('attrib.exe', '+r +h +s '+ExpandConstant('{sd}/boot.ini'), '', SW_HIDE, ewWaitUntilTerminated, iCode);
end;

input:focus,select:focus,textarea:focus{outline: #E2B635 3px solid;}

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值