From 30382f8be040d02abd07029af9ca1a9ee19e74ee Mon Sep 17 00:00:00 2001 From: "Robert C. Maehl" Date: Tue, 6 Jul 2021 00:24:01 -0400 Subject: [PATCH] #412 Continue on #412 --- WhyNotWin11.au3 | 21 ++++------ includes/_Checks.au3 | 93 +++++++++++++++----------------------------- 2 files changed, 38 insertions(+), 76 deletions(-) diff --git a/WhyNotWin11.au3 b/WhyNotWin11.au3 index 2ae75433..4bdff7a2 100644 --- a/WhyNotWin11.au3 +++ b/WhyNotWin11.au3 @@ -48,6 +48,8 @@ If @OSVersion = 'WIN_10' Then DllCall(@SystemDir & "\User32.dll", "bool", "SetPr #include #include +Global $WINDOWS_DRIVE = EnvGet("SystemDrive") + #include ".\Includes\_WMIC.au3" #include ".\Includes\_Checks.au3" #include ".\Includes\Resources.au3" @@ -72,7 +74,6 @@ If @OSBuild >= 22000 Or _WinAPI_GetProcAddress($__g_hModule, "wine_get_host_vers Exit 1 EndIf -Global $WINDOWS_DRIVE = EnvGet("SystemDrive") If $CmdLine[0] > 0 Then ProcessCMDLine() ExtractFiles() Main() @@ -147,7 +148,7 @@ Func ChecksOnly() $aResults[2][1] = @error $aResults[2][2] = @extended - $aResults[3][0] = _CPUCoresCheck() + $aResults[3][0] = _CPUCoresCheck(_GetCPUInfo(0), _GetCPUInfo(1)) $aResults[3][1] = @error $aResults[3][2] = @extended @@ -488,7 +489,7 @@ Func Main() EndIf #Region - Determining CPU properties - If _GetCPUInfo(0) >= 2 Or _GetCPUInfo(1) >= 2 Then + If _CPUCoresCheck(_GetCPUInfo(0), _GetCPUInfo(1)) Then _GUICtrlSetPass($hCheck[3][0]) Else _GUICtrlSetFail($hCheck[3][0]) @@ -542,20 +543,12 @@ Func Main() GUICtrlSetData($hCheck[8][2], _Translate($iMUI, "Disabled / Not Detected")) EndSwitch - Local $aDrives = DriveGetDrive($DT_FIXED) - Local $iDrives = 0 - - For $iLoop = 1 To $aDrives[0] Step 1 - If Round(DriveSpaceTotal($aDrives[$iLoop]) / 1024, 0) >= 64 Then $iDrives += 1 - Next - - - If Round(DriveSpaceTotal($WINDOWS_DRIVE) / 1024, 0) >= 64 Then + If _SpaceCheck() Then _GUICtrlSetPass($hCheck[9][0]) Else _GUICtrlSetFail($hCheck[9][0]) EndIf - GUICtrlSetData($hCheck[9][2], Round(DriveSpaceTotal($WINDOWS_DRIVE) / 1024, 0) & " GB " & $WINDOWS_DRIVE & @CRLF & $iDrives & " " & _Translate($iMUI, "Drive(s) Meet Requirements")) + GUICtrlSetData($hCheck[9][2], @error & " GB " & $WINDOWS_DRIVE & @CRLF & @extended & " " & _Translate($iMUI, "Drive(s) Meet Requirements")) Select Case _GetTPMInfo(0) = False @@ -579,7 +572,7 @@ Func Main() EndSelect #Region Settings GUI - Local $hSettings = GUICreate(_Translate($iMUI, "Settings"), 670, 558, 102, 2, $WS_POPUP, $WS_EX_MDICHILD, $hGUI) + Local $hSettings = GUICreate(_Translate($iMUI, "Settings"), 698, 528, 102, 32, $WS_POPUP, $WS_EX_MDICHILD, $hGUI) Local $bSettings = False GUISetBkColor(_HighContrast(0xF8F8F8)) GUISetFont($aFonts[$FontSmall] * $DPI_RATIO, $FW_BOLD, "", "Arial") diff --git a/includes/_Checks.au3 b/includes/_Checks.au3 index 9708625d..22acb5dd 100644 --- a/includes/_Checks.au3 +++ b/includes/_Checks.au3 @@ -1,5 +1,6 @@ #include-once #include +#include ".\_WMIC.au3" Func _ArchCheck() Select @@ -27,73 +28,40 @@ Func _BootCheck() EndFunc ;==>_BootCheck Func _CPUNameCheck($sCPU) - Local $iLines + Local $iLines, $sLine, $ListFile Select Case StringInStr($sCPU, "AMD") - $iLines = _FileCountLines(@LocalAppDataDir & "\WhyNotWin11\SupportedProcessorsAMD.txt") - If @error Then - SetError(1, 0, 0) - EndIf - Local $sLine - For $iLine = 1 To $iLines Step 1 - $sLine = FileReadLine(@LocalAppDataDir & "\WhyNotWin11\SupportedProcessorsAMD.txt", $iLine) - Select - Case @error = -1 - SetError(2, 0, False) - ExitLoop - Case $iLine = $iLines - SetError(3, 0, False) - ExitLoop - Case StringInStr($sCPU, $sLine) - Return True - ExitLoop - EndSelect - Next + $ListFile = "\WhyNotWin11\SupportedProcessorsAMD.txt" Case StringInStr($sCPU, "Intel") - $iLines = _FileCountLines(@LocalAppDataDir & "\WhyNotWin11\SupportedProcessorsIntel.txt") - If @error Then - SetError(1, 0, 0) - EndIf - For $iLine = 1 To $iLines Step 1 - $sLine = FileReadLine(@LocalAppDataDir & "\WhyNotWin11\SupportedProcessorsIntel.txt", $iLine) - Select - Case @error = -1 - SetError(2, 0, False) - ExitLoop - Case $iLine = $iLines - SetError(3, 0, False) - ExitLoop - Case StringInStr($sCPU, $sLine) - Return True - ExitLoop - EndSelect - Next + $ListFile = "\WhyNotWin11\SupportedProcessorsIntel.txt" Case StringInStr($sCPU, "SnapDragon") Or StringInStr($sCPU, "Microsoft") - $iLines = _FileCountLines(@LocalAppDataDir & "\WhyNotWin11\SupportedProcessorsQualcomm.txt") - If @error Then - SetError(1, 0, 0) - EndIf - For $iLine = 1 To $iLines Step 1 - $sLine = FileReadLine(@LocalAppDataDir & "\WhyNotWin11\SupportedProcessorsQualcomm.txt", $iLine) - Select - Case @error = -1 - SetError(2, 0, False) - ExitLoop - Case $iLine = $iLines - SetError(3, 0, False) - ExitLoop - Case StringInStr($sCPU, $sLine) - Return True - ExitLoop - EndSelect - Next - Case Else - Return False + $ListFile = "\WhyNotWin11\SupportedProcessorsQualcomm.txt" EndSelect + + If $ListFile = Null Then + Return False + Else + $iLines = _FileCountLines(@LocalAppDataDir & $ListFile) + If @error Then Return SetError(1, 0, 0) + For $iLine = 1 To $iLines Step 1 + $sLine = FileReadLine(@LocalAppDataDir & $ListFile, $iLine) + Select + Case @error + SetError(2, 0, False) + ExitLoop + Case $iLine = $iLines + SetError(3, 0, False) + ExitLoop + Case StringInStr($sCPU, $sLine) + Return True + ExitLoop + EndSelect + Next + EndIf EndFunc ;==>_CPUNameCheck -Func _CPUCoresCheck() - If _GetCPUInfo(0) >= 2 Or _GetCPUInfo(1) >= 2 Then +Func _CPUCoresCheck($iCores, $iThreads) + If $iCores >= 2 Or $iThreads >= 2 Then Return True Else Return False @@ -199,6 +167,7 @@ Func _SecureBootCheck() EndFunc ;==>_SecureBootCheck Func _SpaceCheck() + Local $iFree = Round(DriveSpaceTotal($WINDOWS_DRIVE) / 1024, 0) >= 64 Local $aDrives = DriveGetDrive($DT_FIXED) Local $iDrives = 0 @@ -206,10 +175,10 @@ Func _SpaceCheck() If Round(DriveSpaceTotal($aDrives[$iLoop]) / 1024, 0) >= 64 Then $iDrives += 1 Next - If Round(DriveSpaceTotal("C:\") / 1024, 0) >= 64 Then + If $iFree >= 64 Then Return $iDrives Else - SetError($iDrives, 0, 0) + SetError($iFree, $iDrives, 0) EndIf EndFunc ;==>_SpaceCheck