[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;}
總結
以上是生活随笔為你收集整理的[Inno]制作类似矮人工具箱的程序/设置系统启动时间工具的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: perform指标分析_如何看待Perf
- 下一篇: 搜狗输入法如何使用翻译功能--win10