Victor_Dobrov
Advanced Member | Редактировать | Профиль | Сообщение | Цитировать | Сообщить модератору Народ! Оцените переделаный S.T.A.L.K.E.R.-подобный скрипт. Изменения: Сведения о системе показывается в отдельном окне и доступны на любой странице, информация обновляется. Вопрос: можно-ли показывать/скрывать кнопкой свою страницу (не окно) на любом этапе установки? [Setup] AppName=SystemTest AppVerName=SystemTest CreateAppDir=false OutputDir=userdocs: OutputBaseFilename=SystemTest [Files] Source: compiler:get_hw_caps.dll; Flags: dontcopy [Code] const oneMB =1024*1024; LightColor = $EEEEEE; RedColor = $CCCCFF; NeedMB = 512; NeedMHZ = 1800; NeedRAM = 512; NeedVRAM = 128; NeedSwap = 1024; //Прописать, сколько мегабайт необходимо var FormTop, FormFlag: Integer; CancelButton, InfoButton, UpdateButton: TButton; InfoForm: TForm; System, SystemNamePanel, Processor, VideoCardPanel, AudioCardPanel, RAMPanel, PageFilePanel, Hdd: TPanel; type TMemoryStatus = record dwLength, dwMemoryLoad, dwTotalPhys, dwAvailPhys, dwTotalPageFile, dwAvailPageFile, dwTotalVirtual, dwAvailVirtual: Longint; end; procedure GlobalMemoryStatus(var lpBuffer: TMemoryStatus); external 'GlobalMemoryStatus@kernel32.dll'; function GetSystemMetrics(nIndex: Integer):Integer; external 'GetSystemMetrics@user32.dll stdcall'; function sndPlaySound(lpszSoundName: string; uFlags: cardinal):integer; external 'sndPlaySoundA@winmm.dll stdcall'; function GetHardDrivesCount(): Integer; external 'hwc_GetHardDrivesCount@files:get_hw_caps.dll stdcall'; function GetHardDriveName(hdd: Integer): PChar; external 'hwc_GetHardDriveName@files:get_hw_caps.dll stdcall'; function GetHardDriveFreeSpace(hdd: integer): Integer; external 'hwc_GetHardDriveFreeSpace@files:get_hw_caps.dll stdcall'; function GetHardDriveTotalSpace(hdd: integer): Integer; external 'hwc_GetHardDriveTotalSpace@files:get_hw_caps.dll stdcall'; function GetSoundCards(): Integer; external 'hwc_GetSoundCards@files:get_hw_caps.dll stdcall'; function GetSoundCardName(): PChar; external 'hwc_GetSoundCardName@files:get_hw_caps.dll stdcall'; function GetSystemPage(): Integer; external 'hwc_GetSystemPage@files:get_hw_caps.dll stdcall'; function GetSystemPhys(): Integer; external 'hwc_GetSystemPhys@files:get_hw_caps.dll stdcall'; function GetVideoCardName(): PChar; external 'hwc_GetVideoCardName@files:get_hw_caps.dll stdcall'; function GetVidMemLocal(): Integer; external 'hwc_GetVidMemLocal@files:get_hw_caps.dll stdcall'; Procedure UpdateButtonOnClick(Sender: TObject); var ProcessorName: String; Passed: Integer; CpuMHZ: Cardinal; Memory: TMemoryStatus; Begin GetVidMemLocal; GetSoundCards; GlobalMemoryStatus(Memory); Passed:=1; RegQueryDWordValue(HKLM, 'HARDWARE\DESCRIPTION\System\CentralProcessor\0','~MHz', CpuMHZ); RegQueryStringValue(HKLM, 'HARDWARE\DESCRIPTION\System\CentralProcessor\0','ProcessorNameString', ProcessorName); with InfoForm do begin Font.Name:= 'Arial'; Font.Height:= 15; BorderStyle:= bsNone; ClientWidth:= WizardForm.ClientWidth; Left:= WizardForm.Left + 3; Top:= WizardForm.Height - WizardForm.ClientHeight + WizardForm.Top + FormTop; if (FormTop = WizardForm.WizardSmallBitmapImage.Height) then ClientHeight:= WizardForm.Bevel.Top - 9 - WizardForm.WizardSmallBitmapImage.Top - WizardForm.WizardSmallBitmapImage.Height else begin ClientHeight:= WizardForm.WizardBitmapImage.Height - 1; with TNewStaticText.Create(InfoForm) do begin Caption:='Результаты тестирования компьютера:'; Font.Name:= 'Times'; Font.Height:= 24; Font.Color:= $552222; Top:=ScaleX(25); Left:=ScaleX(90); Parent:= InfoForm; end; end; System:=TPanel.Create(InfoForm); with System do begin Caption:= ' О системе'; Color:= LightColor; Parent:= InfoForm; Alignment:=taLeftJustify; if (FormTop = WizardForm.WizardSmallBitmapImage.Height) then Top:= ScaleY(26) else Top:= ScaleY(80); Left:= ScaleX(30); Width:= ScaleX(108); Height:= ScaleY(27); BevelInner:= bvSpace; BevelOuter:= bvLowered; end; SystemNamePanel:=TPanel.Create(InfoForm); with SystemNamePanel do begin Caption:=ExpandConstant(' {reg:HKLM\Software\Microsoft\Windows NT\CurrentVersion,ProductName|}') + ExpandConstant(' {reg:HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion,CSDVersion|}') +' сборка ' +GetWindowsVersionString(); Left:= System.Left + System.Width - 2; Width:= ScaleX(330); Top:= System.Top; Height:= System.Height; Color:= $C0DCC0; Parent:= InfoForm; BevelInner:= bvSpace; BevelOuter:= bvLowered; Alignment:=taLeftJustify; end; Processor:=TPanel.Create(InfoForm); with Processor do begin Caption:= ' Процессор'; Color:= System.Color; Parent:= InfoForm; Alignment:=taLeftJustify; Top:= System.Top + System.Height - 2; Left:= System.Left; Width:= System.Width; Height:= System.Height; BevelInner:= bvSpace; BevelOuter:= bvLowered; end; with TPanel.Create(InfoForm) do begin //CPU Caption:=' '+ ProcessorName+' '+IntToStr(CpuMHZ/1000)+'.'+Copy(IntToStr(CpuMHZ), 2, 3)+'GHz'; Top:= Processor.Top; Left:= SystemNamePanel.Left; Width:= SystemNamePanel.Width; Height:= System.Height; BevelInner:= bvSpace; BevelOuter:= bvLowered; if CpuMHZ < NeedMHZ then begin Color:= RedColor; Passed:= 0; end else Color:= SystemNamePanel.Color; Parent:= InfoForm; Alignment:=taLeftJustify; end; RAMPanel:=TPanel.Create(InfoForm); with RAMPanel do begin Caption:=' Объём памяти'; Color:= System.Color; Parent:= InfoForm; Alignment:=taLeftJustify; Top:=Processor.Top + System.Height - 2; Left:= System.Left; Width:= System.Width; Height:= System.Height; BevelInner:= bvSpace; BevelOuter:= bvLowered; end; with TPanel.Create(InfoForm) do begin //RAM Caption:=' '+IntToStr(Memory.dwTotalPhys/oneMB) +'Мб' +' всего, '+ IntToStr(Memory.dwAvailPhys/oneMB) +'Мб свободно, ' + IntToStr((Memory.dwTotalPhys - Memory.dwAvailPhys)/oneMB) +'Мб используется' Top:=RAMPanel.Top; Left:= SystemNamePanel.Left; Width:= SystemNamePanel.Width; Height:= System.Height; BevelInner:= bvSpace; BevelOuter:= bvLowered; if GetSystemPhys < NeedRAM then begin Color:= RedColor; Passed:= 0; end else Color:= SystemNamePanel.Color; Parent:= InfoForm; Alignment:=taLeftJustify; end; VideoCardPanel:=TPanel.Create(InfoForm); with VideoCardPanel do begin Caption:=' Видеоадаптер'; Color:= System.Color; Parent:= InfoForm; Alignment:=taLeftJustify; Top:=RAMPanel.Top + System.Height - 2; Left:= System.Left; Width:= System.Width; Height:= System.Height; BevelInner:= bvSpace; BevelOuter:= bvLowered; end; with TPanel.Create(InfoForm) do begin //Video Caption:= ' ' + GetVideoCardName+ ', '+ IntToStr(round(GetVidMemLocal/oneMB/64)*64)+'Мб, разрешение '+ IntToStr(GetSystemMetrics(0)) + 'x' +IntToStr(GetSystemMetrics(1)); Top:=VideoCardPanel.Top; Left:= SystemNamePanel.Left; Width:= SystemNamePanel.Width; Height:= System.Height; BevelInner:= bvSpace; BevelOuter:= bvLowered; if round(GetVidMemLocal/oneMB/64)*64 < NeedVRAM then begin Color:= RedColor; Passed:= 0; end else Color:= SystemNamePanel.Color; Parent:= InfoForm; Alignment:=taLeftJustify; end; AudioCardPanel:=TPanel.Create(InfoForm); with AudioCardPanel do begin Caption:=' Звуковая карта'; Color:= System.Color; Parent:= InfoForm; Alignment:=taLeftJustify; Top:=VideoCardPanel.Top + System.Height - 2; Left:= System.Left; Width:= System.Width; Height:= System.Height; BevelInner:= bvSpace; BevelOuter:= bvLowered; end; with TPanel.Create(InfoForm) do begin //Sound if Pos('SB', UpperCase(GetSoundCardName)) > 0 then Caption:=' Creative ' +GetSoundCardName else Caption:=' '+GetSoundCardName Top:=AudioCardPanel.Top; Left:= SystemNamePanel.Left; Width:= SystemNamePanel.Width; Height:= System.Height; BevelInner:= bvSpace; BevelOuter:= bvLowered; if GetSoundCards = 0 then begin Color:= RedColor; Caption:=' Не обнаружено'; Passed:= 0; end else Color:= SystemNamePanel.Color; Parent:= InfoForm; Alignment:=taLeftJustify; end; PageFilePanel:=TPanel.Create(InfoForm); with PageFilePanel do begin Caption:=' Файл подкачки'; Color:= System.Color; Parent:= InfoForm; Alignment:=taLeftJustify; Top:=AudioCardPanel.Top + System.Height - 2; Left:= System.Left; Width:= System.Width; Height:= System.Height; BevelInner:= bvSpace; BevelOuter:= bvLowered; end; with TPanel.Create(InfoForm) do begin //Swap Caption:=' '+IntToStr(GetSystemPage)+'Мб всего, ' + IntToStr((Memory.dwTotalPageFile - Memory.dwAvailPageFile)/oneMB) + 'Мб занято системным кэшем'; Top:=PageFilePanel.Top; Left:= SystemNamePanel.Left; Width:= SystemNamePanel.Width; Height:= System.Height; BevelInner:= bvSpace; BevelOuter:= bvLowered; if GetSystemPage < NeedSwap then begin Color:= RedColor; Passed:= 0; end else Color:= SystemNamePanel.Color; Parent:= InfoForm; Alignment:=taLeftJustify; end; Hdd:=TPanel.Create(InfoForm); with Hdd do begin Caption:=' Системный диск'; Color:= System.Color; Parent:= InfoForm; Alignment:=taLeftJustify; Top:=PageFilePanel.Top + System.Height - 2; Left:= System.Left; Width:= System.Width; Height:= System.Height; BevelInner:= bvSpace; BevelOuter:= bvLowered; end; with TPanel.Create(InfoForm) do begin //Hdd Caption:=' '+IntToStr(GetHardDriveTotalSpace(0))+'Мб всего, '+ IntToStr(GetHardDriveFreeSpace(0))+'Мб свободно на '+ RemoveBackslash(Uppercase(GetHardDriveName(0))) Top:=Hdd.Top; Left:= SystemNamePanel.Left; Width:= SystemNamePanel.Width; Height:= System.Height; BevelInner:= bvSpace; BevelOuter:= bvLowered; if GetHardDriveFreeSpace(0) < NeedMB then begin Caption:= Caption +' (нужно ' + IntToStr(NeedMB) + 'Мб)' ; Color:= RedColor; Passed:= 0; end else Color:= SystemNamePanel.Color; Parent:= InfoForm; Alignment:=taLeftJustify; end; with TNewStaticText.Create(InfoForm) do begin Top:=Hdd.Top+30; Left:=System.Left + 8; AutoSize:=True; Parent:= InfoForm; if Passed = 1 then Caption:= #13 + 'Всё оборудование соответствуют требованиям программы.' else Caption:='Не все компоненты соответствуют требованиям программы,' #13#9 'проверьте позиции, выделеные красным цветом.'; end; Show; end; End; Function NextButtonClick(CurPageID: Integer): Boolean; Begin Result:= True; If (InfoButton.Tag = 1) then begin InfoForm.Close; InfoButton.Tag:= 0; InfoButton.Caption:= 'О системе'; end; End; Procedure InfoButtonOnClick(Sender: TObject); Begin if (InfoButton.Tag = 0) then begin if (FormFlag = 0) then FormFlag:= 1; if (FormFlag = 2) then FormFlag:= 3; InfoForm:=TForm.create(nil); UpdateButton:= TButton.Create(InfoForm); with UpdateButton do begin Width:= CancelButton.Width; Height:= CancelButton.Height; Top:= WizardForm.WizardBitmapImage.Height - (CancelButton.Top - WizardForm.Bevel.Top) - (WizardForm.Height - WizardForm.ClientHeight + WizardForm.Top + FormTop - WizardForm.Top); Left:= WizardForm.ClientWidth - (WizardForm.ClientWidth - CancelButton.Left); Caption:= 'Обновить'; OnClick:= @UpdateButtonOnClick; Parent:= InfoForm; end; UpdateButton.OnClick(UpdateButton); InfoButton.Caption:= 'Скрыть сведения'; InfoButton.Tag:= 1; end else begin InfoForm.Close; InfoButton.Caption:= 'О системе'; InfoButton.Tag:= 0; end; End; Procedure CurPageChanged(CurPageID: Integer); Begin If (CurPageID = wpWelcome) or (CurPageID = wpFinished) then FormTop:=-3 else FormTop:=WizardForm.WizardSmallBitmapImage.Height; End; Procedure InitializeWizard(); Begin CancelButton:= WizardForm.CancelButton; InfoButton:= TButton.Create(WizardForm); with InfoButton do begin Width:= CancelButton.Width + ScaleX(25); Left:= WizardForm.ClientWidth - CancelButton.Left - CancelButton.Width; Top:= CancelButton.Top; Height:= CancelButton.Height; Caption:= 'О системе'; OnClick:= @InfoButtonOnClick; Cursor:= crHelp; Parent:= WizardForm; Tag:= 0; end; End; |