GloThin
Тобольский шашлычник | Редактировать | Профиль | Сообщение | ICQ | Цитировать | Сообщить модератору ;Script by Sampron Edit by NightW0lf для "проверки ОС пользователя".//исправленному верить - GloThin [Setup] ;Название программы - инсталлятора, а также заголовок инсталлятора, (пожеланию можно версию указать): AppName=Check_Sys_Requir ;Версия программы - инсталлятора, (пожеланию можно указать - название + версию): AppVerName=1.1 ;Директория установки для программы - инсталлятора: DefaultDirName=C:\Check_Sys_Requir ;Название выходного файла компилятора: OutputBaseFilename=Check_Sys_Requir UserInfoPage=True Compression=lzma/ultra SolidCompression=yes InternalCompressLevel=ultra [FILES] Source: get_hw_caps.dll; Flags: dontcopy [Code] var state: boolean; 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 GetLogicalDrives: DWORD; external 'GetLogicalDrives@kernel32.dll stdcall'; function GetDriveType(nDrive: string): Longint; external 'GetDriveTypeA@kernel32.dll stdcall'; 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 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; 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 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.Name := 'Courier New'; ListBox.Font.Size := 10; ListBox.Font.Style := [fsBold]; 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); if FreeMB>1024 then ListBox.Items.Add(Path + ' ' + IntToStr(round(FreeMB / TotalMB * 100)) + '% ' + floatToStr(round(FreeMB/1024*100)/100) + ' GB') else ListBox.Items.Add(Path + ' ' + IntToStr(round(FreeMB / TotalMB * 100)) + '% ' + IntToStr(FreeMB) + ' MB'); end; end; end; end; function NextButtonClick(CurPageID: Integer): Boolean; var Path,s: 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*1024) then begin if FreeMB>1024 then begin s:='Для установки приложения необходимо '+ IntTostr(NeedSize)+ ' GB,'#13+'а на выбранном Вами диске доступно только '+ floatToStr(round(FreeMB/1024*100)/100) + ' GB!' end else s:='Для установки приложения необходимо '+ IntTostr(NeedSize)+ ' GB,'#13+'а на выбранном Вами диске доступно только '+ + IntToStr(FreeMB)+' MB'; MsgBox(s, mbCriticalError, MB_OK) Result := False; end; end; end; procedure CurPageChanged(CurPageID: Integer); var Page: TWizardPage; Text: TNewStaticText; Memo,Windows,SP,Version,Build,registered,WindowsName,SP_Num,Version_Num,Build_num,registered_name: TMemo; Os,OS1: string; // строка с названием необходимой ОС // state: boolean; ProcessorName: string; Processor, VideoCardPanel, AudioCardPanel, RAMPanel, PageFilePanel: TMemo; ProcessorNamePanel, VideoCardNamePanel, AudioCardNamePanel, RAMTotalPanel, PageFileTotalPanel: TMemo; ProcessorMHZ: Cardinal; StaticText, StaticText2: TNewStaticText; VidRam: integer; begin if CurPageID = wpUserInfo then begin //подменяем сраницу информации о пользователе на информацию об ОС wizardForm.UserInfoNameEdit.visible:=false; wizardForm.UserInfoNameEdit.text:='Игрок'; //на случай, когда имя пользователя не указано в системе wizardForm.UserInfoNameLabel.visible:=false; wizardForm.UserInfoOrgLabel.visible:=false; wizardForm.UserInfoOrgEdit.visible:=false; wizardForm.UserInfoOrgEdit.text:='Группа игроков ';//на случай, когда организация не указано в системе wizardForm.PageNameLabel.Caption := 'Аппаратное обеспечение и Операционная система'; wizardForm.PageDescriptionLabel.Caption := 'Программа установки обнаружила следующие необходимые компоненты и Операционную систему '; RegQueryStringValue(HKLM, 'HARDWARE\DESCRIPTION\System\CentralProcessor\0', 'ProcessorNameString', ProcessorName); RegQueryDWordValue(HKLM, 'HARDWARE\DESCRIPTION\System\CentralProcessor\0', '~MHz', ProcessorMHZ); OS:=' Microsoft Windows XP Service Pack 2'; //строка является суммой из записей в реестре о Наименовании ОС и сервис-паке OS1:=' Microsoft Windows 2000 Service Pack 4'; //строка является суммой из записей в реестре о Наименовании ОС и сервис-паке Windows := TMemo.Create(WizardForm); StaticText := TNewStaticText.Create(TNewStaticText.Create(WizardForm)); with StaticText do begin Left := 0; Top := 52; Width := 417; Height := 14; Caption := 'Все компоненты удовлетворяют требованиям игры.'; Parent := WizardForm.UserInfoPage; StaticText.font.color:=clGreen; end with Windows do begin Text := ' Операц. система'; Parent := WizardForm.UserInfoPage; Left := ScaleX(0); //оригинал S.T.A.L.K.E.R. Top := ScaleY(20); 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 Processor := TMemo.Create(WizardForm); with Processor do begin Text := ' Процессор'; Parent := WizardForm.UserInfoPage; Left := ScaleX(0); //оригинал S.T.A.L.K.E.R. Top := ScaleY(77); 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 VideoCardPanel := TMemo.Create(WizardForm); with VideoCardPanel do begin Text := ' Видеоадаптер'; Parent := WizardForm.UserInfoPage; Left := ScaleX(0); //оригинал S.T.A.L.K.E.R. Top := ScaleY(104); 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 AudioCardPanel := TMemo.Create(WizardForm); with AudioCardPanel do begin Text := ' Звуковая карта'; Parent := WizardForm.UserInfoPage; Color := clBtnFace; Left := ScaleX(0); //оригинал S.T.A.L.K.E.R. Top := ScaleY(131); Width := ScaleX(106); //оригинал S.T.A.L.K.E.R. Height := ScaleY(22); //оригинал S.T.A.L.K.E.R. ReadOnly := True; end RAMPanel := TMemo.Create(WizardForm); with RAMPanel do begin Text := ' ОЗУ'; Parent := WizardForm.UserInfoPage; Color := clBtnFace; Left := ScaleX(0); //оригинал S.T.A.L.K.E.R. Top := ScaleY(158); Width := ScaleX(106); //оригинал S.T.A.L.K.E.R. Height := ScaleY(22); //оригинал S.T.A.L.K.E.R. ReadOnly := True; end PageFilePanel := TMemo.Create(WizardForm); with PageFilePanel do begin Text := ' Файл подкачки'; Parent := WizardForm.UserInfoPage; Color := clBtnFace; Left := ScaleX(0); //оригинал S.T.A.L.K.E.R. Top := ScaleY(185); Width := ScaleX(106); //оригинал S.T.A.L.K.E.R. Height := ScaleY(22); //оригинал S.T.A.L.K.E.R. ReadOnly := True; ProcessorNamePanel := TMemo.Create(WizardForm); with ProcessorNamePanel do begin Text := DelSP(ProcessorName) + ' ' + IntToStr(ProcessorMHZ) + 'MHz'; //новое обработанное значение строки Parent := WizardForm.UserInfoPage; Left := ScaleX(110); //оригинал S.T.A.L.K.E.R. Top := ScaleY(77); Width := ScaleX(304); //оригинал S.T.A.L.K.E.R. Height := ScaleY(22); //оригинал S.T.A.L.K.E.R. ReadOnly := True; Color := $CCFFCC; if ProcessorMHZ < 1800 then begin ProcessorNamePanel.Color := $ccccff; StaticText.Caption := 'Не все компоненты удовлетворяют требованиям игры.'; StaticText.font.color:=clRed; end; VideoCardNamePanel := TMemo.Create(WizardForm); with VideoCardNamePanel do begin Text := ' ' + GetVideoCardName; //+' ОЗУ-'+inttostr(round(GetVidMemLocal/1000000))+' МБ' Parent := WizardForm.UserInfoPage; 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 := ScaleY(104); Width := ScaleX(304); //оригинал S.T.A.L.K.E.R. Height := ScaleY(22); //оригинал S.T.A.L.K.E.R. ReadOnly := True; Color := $CCFFCC; if GetVidMemLocal < 127000000 then //128 MB begin StaticText.Caption := 'Не все компоненты удовлетворяют требованиям игры.'; StaticText.font.color:=clRed; VideoCardNamePanel.Color := $ccccff; end; end AudioCardNamePanel := TMemo.Create(WizardForm); with AudioCardNamePanel do begin Text := ' ' + GetSoundCardName; Parent := WizardForm.UserInfoPage; Color := $CCFFCC; Left := ScaleX(110); //оригинал S.T.A.L.K.E.R. Top := ScaleY(131); Width := ScaleX(304); //оригинал S.T.A.L.K.E.R. Height := ScaleY(22); //оригинал S.T.A.L.K.E.R ReadOnly := True; end RAMTotalPanel := TMemo.Create(WizardForm); with RAMTotalPanel do begin Text := ' ' + IntToStr(GetSystemPhys + 1) + ' MB'; Parent := WizardForm.UserInfoPage; Color := $CCFFCC; Left := ScaleX(110); //оригинал S.T.A.L.K.E.R. Top := ScaleY(158); Width := ScaleX(304); //оригинал S.T.A.L.K.E.R. Height := ScaleY(22); //оригинал S.T.A.L.K.E.R. ReadOnly := True; if GetSystemPhys + 1 < 1024 then begin RAMTotalPanel.Color := $ccccff; StaticText.Caption := 'Не все компоненты удовлетворяют требованиям игры.'; StaticText.font.color:=clRed; end; end; PageFileTotalPanel := TMemo.Create(WizardForm); with PageFileTotalPanel do begin Text := ' ' + IntToStr(GetSystemPage) + ' MB'; Parent := WizardForm.UserInfoPage; Color := $CCFFCC; Left := ScaleX(110); //оригинал S.T.A.L.K.E.R. Top := ScaleY(185); Width := ScaleX(304); //оригинал S.T.A.L.K.E.R. Height := ScaleY(22); //оригинал S.T.A.L.K.E.R. ReadOnly := True; if GetSystemPage < 1247 then begin PageFileTotalPanel.Color := $ccccff; StaticText.Caption := 'Не все компоненты удовлетворяют требованиям игры.'; StaticText.font.color:=clRed; end; end; end if ExpandConstant('{reg:HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion,ProductName|}')='' then begin WindowsName := TMemo.Create(WizardForm); with WindowsName do begin Text := ExpandConstant(' {reg:HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion,ProductName|}')+ExpandConstant(' {reg:HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion,CSDVersion|}'); Parent := WizardForm.UserInfoPage; Left := ScaleX(110); //оригинал S.T.A.L.K.E.R. Top := ScaleY(20); 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 end end; // Проверка Windows 9x if ExpandConstant('{reg:HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion,ProductName|}')<>'' then begin WindowsName := TMemo.Create(WizardForm); with WindowsName do begin Text := ExpandConstant(' {reg:HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion,ProductName|}')+ExpandConstant(' {reg:HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion,CSDVersion|}'); Parent := WizardForm.UserInfoPage; Color := $CCFFCC; Left := ScaleX(110); //оригинал S.T.A.L.K.E.R. Top := ScaleY(20); Width := ScaleX(304); //оригинал S.T.A.L.K.E.R. Height := ScaleY(22); //оригинал S.T.A.L.K.E.R. ReadOnly := True; end end; if OS=(WindowsName.Text) then state:=true else if OS1=(WindowsName.Text) then state:=true else state:=false; Text := TNewStaticText.Create(WizardForm); with Text do begin Left := 0; Top := 0; Width := 417; Height := 14; if state then begin Font.Color:=clGreen; WindowsName.color:=$CCFFCC; // SP_Num.color:=$CCFFCC; Caption := 'Операционная система соответствует требованиям игры.'; end else begin Font.Color:=clREd; WindowsName.color:=clRed; WindowsName.Left := ScaleX(110); //оригинал S.T.A.L.K.E.R. WindowsName.Top := ScaleY(20); WindowsName.Width := ScaleX(304); //оригинал S.T.A.L.K.E.R. WindowsName.Height := ScaleY(22); //оригинал S.T.A.L.K.E.R. WindowsName.ReadOnly := True; Caption := 'Операционная система не соответствует требованиям игры.'; end Parent := WizardForm.UserInfoPage; end Text := TNewStaticText.Create(TNewStaticText.Create(WizardForm)); with Text do begin Left := 0; Top := 220; Width := 417; Height := 14; Caption := 'Когда Вы будете готовы продолжить установку, нажмите «Далее».'; Parent := WizardForm.UserInfoPage; end if not state then begin wizardForm.Nextbutton.enabled:=false; end; end; end; |