GRom V
Full Member | Редактировать | Профиль | Сообщение | ICQ | Цитировать | Сообщить модератору Sampron Цитата: как обьединить твой скрипт и например этот, т е чтоб проверка производилась при нажатии кнопки тест? 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; var ListBox: TListBox; Text: TNewStaticText; function GetVideoCardName(): PChar; external 'hwc_GetVideoCardName@files:get_hw_caps.dll stdcall'; function GetSoundCardName(): PChar; external 'hwc_GetSoundCardName@files:get_hw_caps.dll stdcall'; function DetectHardware(): Integer; external 'hwc_DetectHardware@files:get_hw_caps.dll stdcall'; function GetHardDriveFreeSpace(hdd: integer): Integer; external 'hwc_GetHardDriveFreeSpace@files:get_hw_caps.dll stdcall'; function GetHardDriveName(hdd: integer): PChar; external 'hwc_GetHardDriveName@files:get_hw_caps.dll stdcall'; function GetHardDriveTotalSpace(hdd: integer): Integer; external 'hwc_GetHardDriveTotalSpace@files:get_hw_caps.dll stdcall'; function GetHardDrivesCount(): Integer; external 'hwc_GetHardDrivesCount@files:get_hw_caps.dll stdcall'; function GetSoundCards(): Integer; external 'hwc_GetSoundCards@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 GetVidMemLocal(): Integer; external 'hwc_GetVidMemLocal@files:get_hw_caps.dll stdcall'; function GetVidMemNonLocal(): Integer; external 'hwc_GetVidMemNonLocal@files:get_hw_caps.dll stdcall'; function GetVideoCardDev(): Integer; external 'hwc_GetVideoCardDev@files:get_hw_caps.dll stdcall'; function GetVideoCardVen(): Integer; external 'hwc_GetVideoCardVen@files:get_hw_caps.dll stdcall'; function GetLogicalDrives: DWORD; external 'GetLogicalDrives@kernel32.dll stdcall'; function GetDriveType(nDrive: string): Longint; external 'GetDriveTypeA@kernel32.dll stdcall'; function DelSp(const s: string): string; //функция удаления табуляции и пробелов в начале строки var c, i: integer; stt, st, st1: string; begin c := 0; st := s; for i := 1 to Length(st) do begin stt := copy(st, i, 1); if (stt = ' ') and (c >= 1) then begin st1 := st1; c := c + 1; end else if (stt = ' ') and (c = 0) then begin c := c + 1; st1 := st1 + stt; end else if (stt <> ' ') then begin c := 0; st1 := st1 + stt; end end; Result := st1; end; function CheckSystemPage(PreviousPageId: Integer): Integer; var Page: TWizardPage; ProcessorName: string; Processor, VideoCardPanel, AudioCardPanel, RAMPanel, PageFilePanel: TMemo; ProcessorNamePanel, VideoCardNamePanel, AudioCardNamePanel, RAMTotalPanel, PageFileTotalPanel: TMemo; ProcessorMHZ: Cardinal; StaticText, StaticText2: TNewStaticText; VidRam: integer; begin RegQueryStringValue(HKLM, 'HARDWARE\DESCRIPTION\System\CentralProcessor\0', 'ProcessorNameString', ProcessorName); RegQueryDWordValue(HKLM, 'HARDWARE\DESCRIPTION\System\CentralProcessor\0', '~MHz', ProcessorMHZ); GetVidMemLocal; GetSoundCards; Page := CreateCustomPage(PreviousPageId, 'Аппаратное Обеспечение', 'Программа установки обнаружила следующие необходимые компоненты'); StaticText := TNewStaticText.Create(Page); with StaticText do begin Parent := Page.Surface; Caption := 'Все компоненты соответствуют требованиям игры.'; Left := 0; Top := 0; AutoSize := True; end; StaticText2 := TNewStaticText.Create(Page); with StaticText2 do begin Parent := Page.Surface; Caption := 'Когда Вы будите, готовы продолжить установку, нажмите «Далее».'; Left := 0; Top := 220; AutoSize := True; end; //******************************************* [Начало - Процессор] ***************************************************// Processor := TMemo.Create(Page); with Processor do begin Text := ' Процессор'; Alignment := taLeftJustify; Parent := Page.Surface; Left := ScaleX(0); //оригинал S.T.A.L.K.E.R. Top := ScaleY(30); Width := ScaleX(106); //оригинал S.T.A.L.K.E.R. Height := ScaleY(22); //оригинал S.T.A.L.K.E.R. ReadOnly := True; Color := clBtnFace; end; ProcessorNamePanel := TMemo.Create(Page); with ProcessorNamePanel do begin Text := DelSP(ProcessorName) + ' ' + IntToStr(ProcessorMHZ) + 'MHz'; //новое обработанное значение строки //Caption :=ProcessorName+' '+IntToStr(ProcessorMHZ)+'MHz' ; Alignment := taLeftJustify; Parent := Page.Surface; Left := ScaleX(110); //оригинал S.T.A.L.K.E.R. Top := ScaleY(30); Width := ScaleX(304); //оригинал S.T.A.L.K.E.R. Height := ScaleY(22); //оригинал S.T.A.L.K.E.R. ReadOnly := True; Color := $CCFFCC; end; if ProcessorMHZ < 1800 then //Минимальное количество частоты в MHz begin StaticText.Caption := 'Не все компоненты удовлетворяют требованиям игры.'; ProcessorNamePanel.Color := $CCCCFF; end; //******************************************* [Конец - Процессор] ****************************************************// //******************************************* [Начало - Видеоадаптер] ************************************************// VideoCardPanel := TMemo.Create(Page); with VideoCardPanel do begin Text := ' Видеоадаптер'; Alignment := taLeftJustify; Parent := Page.Surface; Left := ScaleX(0); //оригинал S.T.A.L.K.E.R. Top := Processor.Top + 27; Width := ScaleX(106); //оригинал S.T.A.L.K.E.R. Height := ScaleY(22); //оригинал S.T.A.L.K.E.R. ReadOnly := True; Color := clBtnFace; end; VideoCardNamePanel := TMemo.Create(Page); with VideoCardNamePanel do begin Text := ' ' + GetVideoCardName; //+' ОЗУ-'+inttostr(round(GetVidMemLocal/1000000))+' МБ'; //Caption:=' ОЗУ-'+inttostr(GetVidMemLocal)+' МБ'; Alignment := taLeftJustify; Parent := Page.Surface; VidrAM := GetVidMemLocal / 1000000; if VidRam > 127 then begin if VidRam < 200 then Text := Text + ' ОЗУ - 128 МB' else if VidRam < 300 then Text := Text + ' ОЗУ - 256 МB' else if VidRam < 400 then Text := Text + ' ОЗУ - 384 МB' else if VidRam > 500 then Text := Text + ' ОЗУ - 512 МB'; end; Left := ScaleX(110); //оригинал S.T.A.L.K.E.R. Top := VideoCardPanel.Top; Width := ScaleX(304); //оригинал S.T.A.L.K.E.R. Height := ScaleY(22); //оригинал S.T.A.L.K.E.R. ReadOnly := True; Color := $CCFFCC; end; if GetVidMemLocal < 127000000 then //Минимальное объем ОЗУ [в байтах] у видеоадаптера 128 MB begin StaticText.Caption := 'Не все компоненты удовлетворяют требованиям игры.'; VideoCardNamePanel.Color := $CCCCFF; end; //******************************************* [Конец - Видеоадаптер] *************************************************// //******************************************* [Начало - Звуковая карта] **********************************************// AudioCardPanel := TMemo.Create(Page); with AudioCardPanel do begin Text := ' Звуковая карта'; Alignment := taLeftJustify; Parent := Page.Surface; Left := ScaleX(0); //оригинал S.T.A.L.K.E.R. Top := VideoCardPanel.Top + 27; Width := ScaleX(106); //оригинал S.T.A.L.K.E.R. Height := ScaleY(22); //оригинал S.T.A.L.K.E.R. ReadOnly := True; Color := clBtnFace; end; AudioCardNamePanel := TMemo.Create(Page); with AudioCardNamePanel do begin Text := ' ' + GetSoundCardName; Alignment := taLeftJustify; Parent := Page.Surface; Left := ScaleX(110); //оригинал S.T.A.L.K.E.R. Top := AudioCardPanel.Top; Width := ScaleX(304); //оригинал S.T.A.L.K.E.R. Height := ScaleY(22); //оригинал S.T.A.L.K.E.R. ReadOnly := True; Color := $CCFFCC; end; if GetSoundCards = 0 then begin StaticText.Caption := 'Не все компоненты удовлетворяют требованиям игры.'; AudioCardNamePanel.Color := $CCCCFF; end; //******************************************* [Конец - Звуковая карта] ***********************************************// //******************************************* [Начало - ОЗУ] *********************************************************// RAMPanel := TMemo.Create(Page); with RAMPanel do begin Text := ' ОЗУ'; Alignment := taLeftJustify; Parent := Page.Surface; Left := ScaleX(0); //оригинал S.T.A.L.K.E.R. Top := AudioCardPanel.Top + 27; Width := ScaleX(106); //оригинал S.T.A.L.K.E.R. Height := ScaleY(22); //оригинал S.T.A.L.K.E.R. ReadOnly := True; Color := clBtnFace; end; RAMTotalPanel := TMemo.Create(Page); with RAMTotalPanel do begin Text := ' ' + IntToStr(GetSystemPhys + 1) + ' MB'; Alignment := taLeftJustify; Parent := Page.Surface; Left := ScaleX(110); //оригинал S.T.A.L.K.E.R. Top := RAMPanel.Top; Width := ScaleX(304); //оригинал S.T.A.L.K.E.R. Height := ScaleY(22); //оригинал S.T.A.L.K.E.R. ReadOnly := True; Color := $CCFFCC; end; if GetSystemPhys + 1 < 1024 then //Минимальное объем ОЗУ 1 Гб или 1024 Мб begin StaticText.Caption := 'Не все компоненты удовлетворяют требованиям игры.'; RAMTotalPanel.Color := $CCCCFF; end; //******************************************* [Конец - ОЗУ] **********************************************************// //******************************************* [Начало - Файл подкачки] ***********************************************// PageFilePanel := TMemo.Create(Page); with PageFilePanel do begin Text := ' Файл подкачки'; Alignment := taLeftJustify; Parent := Page.Surface; Left := ScaleX(0); //оригинал S.T.A.L.K.E.R. Top := RAMPanel.Top + 27; Width := ScaleX(106); //оригинал S.T.A.L.K.E.R. Height := ScaleY(22); //оригинал S.T.A.L.K.E.R. ReadOnly := True; Color := clBtnFace; end; PageFileTotalPanel := TMemo.Create(Page); with PageFileTotalPanel do begin Text := ' ' + IntToStr(GetSystemPage) + ' MB'; Alignment := taLeftJustify; Parent := Page.Surface; Left := ScaleX(110); //оригинал S.T.A.L.K.E.R. Top := PageFilePanel.Top; Width := ScaleX(304); //оригинал S.T.A.L.K.E.R. Height := ScaleY(22); //оригинал S.T.A.L.K.E.R. ReadOnly := True; Color := $CCFFCC; end; if GetSystemPage < 1024 then //Минимальное объем файла [в мегабайтах] подкачки 1 Гб или 1024 Мб begin StaticText.Caption := 'Не все компоненты удовлетворяют требованиям игры.'; PageFileTotalPanel.Color := $CCCCFF; end; Result := Page.ID; end; //******************************************* [Конец - Файл подкачки] ************************************************// procedure ListBoxOnClick(Sender: TObject); var NewLetter, OldString: string; i: Integer; begin for i := 0 to ListBox.Items.Count - 1 do begin if ListBox.Selected[i] then begin NewLetter := Copy(ListBox.Items[i], 0, 1); OldString := Copy(WizardForm.DirEdit.Text, 2, Length(WizardForm.DirEdit.Text)); WizardForm.DirEdit.Text := NewLetter + OldString; end; end; end; procedure InitializeWizard(); var Page: TWizardPage; Text: TNewStaticText; Memo: TMemo; Path: string; FreeMB, TotalMB: Cardinal; drives: DWORD; i: integer; begin CheckSystemPage(wpLicense); Text := TNewStaticText.Create(WizardForm); Text.Top := 102; Text.Width := 332; Text.Height := 14; Text.Caption := 'Список жестких дисков и свободного места'; Text.Parent := WizardForm.SelectDirPage; ListBox := TListBox.Create(WizardForm); ListBox.Top := 120; ListBox.Width := 332; ListBox.Height := ScaleY(90); ListBox.Parent := WizardForm.SelectDirPage; ListBox.OnClick := @ListBoxOnClick; ListBox.Font.Style := [fsBold]; ListBox.Font.Name := 'Courier New'; ListBox.Font.Size := 10; ListBox.Color := clBtnFace; 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(round(FreeMB/TotalMB*100)) + '% ' + IntToStr(FreeMB) + ' MB'); 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; |