Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
rcmaehl committed Oct 15, 2021
1 parent 6786ae4 commit e6269e2
Show file tree
Hide file tree
Showing 5 changed files with 123 additions and 94 deletions.
3 changes: 1 addition & 2 deletions WhyNotWin11.au3
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@ FileChangeDir(@SystemDir)

Global $WINDOWS_DRIVE = EnvGet("SystemDrive")

#include "Includes\GetDiskInfo.au3"
#include "Includes\ResourcesEx.au3"

#include "Includes\_WMIC.au3"
#include "Includes\_Checks.au3"
#include "Includes\_Theming.au3"
#include "Includes\_Resources.au3"
#include "Includes\_GetDiskInfo.au3"
#include "Includes\_Translations.au3"
; #include "includes\WhyNotWin11_accessibility.au3"

Expand Down Expand Up @@ -196,7 +196,6 @@ Func ProcessCMDLine()
If $aResults[$iLoop][0] = False Or $aResults[$iLoop][0] < 1 Then Exit 1
Next
Exit 0

EndFunc ;==>ProcessCMDLine

Func RunChecks()
Expand Down
7 changes: 5 additions & 2 deletions includes/GetDiskInfoFromWmi.au3 → includes/GetDiskInfo.au3
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,15 @@
Language ............: English
Description .........: Get disk and partition informations from WMI.
Author ..............: htcfreek (Heiko) - https://github.com/htcfreek [original]
Modified ............:
Modified ............: 2021-07-12 (htcfreek): Temporary fix build warnings until new version is released.
Required includes ...: Array.au3
Dll .................:
===============================================================================================================================
CHANGELOG:
2021-07-12 (v1.4.1 + temporary fix)
Fix: Build warings for non declared vars $sDiskHeader, $sPartitionHeader
2021-07-06 (v1.4.1)
Fixed: Code styling
Expand Down Expand Up @@ -150,4 +153,4 @@ Func _GetDiskInfoFromWmi(ByRef $aDiskList, ByRef $aPartitionList, $bAddTableHead
; Return Data
$aDiskList = $aDisks
$aPartitionList = $aPartitions
EndFunc ;==>_GetDiskInfoFromWmi
EndFunc ;==>_GetDiskInfoFromWmi
55 changes: 53 additions & 2 deletions includes/_Checks.au3
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#include-once
#include <File.au3>
#include ".\_WMIC.au3"
#include <WinAPIDiag.au3>

#include ".\_WMIC.au3"


Func _ArchCheck()
Select
Case @CPUArch = "X64" And @OSArch = "IA64"
Expand Down Expand Up @@ -123,7 +125,7 @@ Func _GetDirectXCheck(ByRef $aArray)
EndFunc ;==>_GetDirectXCheck

Func _GPTCheck($aDisks)
For $iLoop = 0 To UBound($aDisks) - 1
For $iLoop = 1 To UBound($aDisks) - 1
If $aDisks[$iLoop][11] = "True" Then
Switch $aDisks[$iLoop][9]
Case "GPT"
Expand All @@ -134,7 +136,56 @@ Func _GPTCheck($aDisks)
EndIf
Next
EndFunc ;==>_GPTCheck
#cs
Func _GPTCheck($iFlag)
; Desc ......... : Call _GetDiskInfoFromWmi() to get the disk and partition informations. The selected information will be returned.
; Parameters ... : $iFlag = 0 => Return init type of system disk.
; .............. : $iFlag = 1 => Return count of internal GPT disks.
; .............. : $iFlag = 2 => Return count of all internal disks.
; .............. : $iFlag = 3 => Return array with all disk. (Columns: DiskNum | InitType | CheckResult)
; On error ..... : SetError(1, 1, "Error_CheckFailed")
; Vars
Local Static $aDisks
If ($aDisks = Null) Then
$aDisks = _GetDiskProperties(1) ; Array with all disks
If @error = 1 Then Return SetError(1, 1, "Error_CheckFailed")
EndIf
Local $aReturnDiskArray[0][3]
_ArrayAdd($aReturnDiskArray, "Disk" & "|" & "Type" & "|" & "Check result")
; Return data based on $iFlag
Switch $iFlag
Case 0
; Return data of system disk.
Switch _GetDiskProperties(3)[0][9] ; 9 = Array field for DiskInitType
Case "GPT"
Return True
Case "MBR"
Return False
EndSwitch
Case 1
; Count int. GPT disks
Local $iDiskCount = 0
For $i = 1 To UBound($aDisks) - 1
If $aDisks[$i][9] = "GPT" Then
$iDiskCount += 1
EndIf
Next
Return $iDiskCount
Case 2
; Return count of all int. disks
Return UBound($aDisks)
Case 3
; Return array with all disk in the format Number|Type|Result
For $i = 0 To UBound($aDisks) - 1
Local $sDiskRow = $aDisks[$i][0] & "|" & $aDisks[$i][9] & "|" & (($aDisks[$i][9] = "GPT") ? "True" : "False")
_ArrayAdd($aReturnDiskArray, $sDiskRow)
Next
Return $aReturnDiskArray
EndSwitch
EndFunc ;==>_GPTCheck
#ce
Func _InternetCheck()
Return _WinAPI_IsInternetConnected()
EndFunc
Expand Down
88 changes: 0 additions & 88 deletions includes/_GetDiskInfo.au3

This file was deleted.

64 changes: 64 additions & 0 deletions includes/_WMIC.au3
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#include-once

#include <Array.au3>
#include <StringConstants.au3>

#include "GetDiskInfo.au3"

Func _GetCPUInfo($iFlag = 0)
Local Static $sCores
Local Static $sThreads
Expand Down Expand Up @@ -92,6 +96,66 @@ Func _GetDiskInfo($iFlag = 0)
EndSwitch
EndFunc ;==>_GetDiskInfo

Func _GetDiskProperties($iFlag = 0)
; Desc ......... : Call _GetDiskInfoFromWmi() to get the disk and partition informations. The selected information will be returned.
; Parameters ... : $iFlag = 0 => Init WMI data.
; .............. : $iFlag = 1 => Return array with disk information.
; .............. : $iFlag = 2 => Return array with partition information.
; .............. : $iFlag = 3 => Return information of disk with system (Windows) partition.
; .............. : $iFlag = 4 => Return information of system (Windows) partition.
; On error ..... : Return SetError(1, 1, "Error_WmiFailed"), if WMI failed.
; .............. : Return SetError(1, 2, "Error_IncorrectFlag"), if $iFlag is unknown.
; .............. : Return SetError(1, 3, "Error_NoDataReturned"), if not data can be returned.

Local Static $aDiskArray
Local Static $aPartitionArray
Local Static $aSysDisk
Local Static $aSysPartition

#forcedef $DiskInfoWmi_TableHeader_No
#forcedef $DiskInfoWmi_DiskType_Fixed

; Get WMI data
If ($aDiskArray = "") Or ($aPartitionArray = "") Then
; Get disk datat for fixed (internal) disks.
_GetDiskInfoFromWmi($aDiskArray, $aPartitionArray, $DiskInfoWmi_TableHeader_No, $DiskInfoWmi_DiskType_Fixed)
If @error = 1 Then Return SetError(1, 1, "Error_WmiFailed")
EndIf

; Get sys disk and sys partition num
If ($aSysDisk = "") Or ($aSysPartition = "") Then
Local $iSysDisk = _ArraySearch($aDiskArray, "True", 0, 0, 0, 0, 1, 11) ; Row 11 = IsSysDisk
$aSysDisk = _ArrayExtract($aDiskArray, $iSysDisk, $iSysDisk)
Local $iSysPartition = _ArraySearch($aPartitionArray, "True", 0, 0, 0, 0, 1, 12) ; Row 12 = IsSysPartition
$aSysPartition = _ArrayExtract($aPartitionArray, $iSysPartition, $iSysPartition)
EndIf

; Return data based on $iFlag or exit function
Switch $iFlag
Case 0
; Exit function after init WMI data
Return
Case 1
; Return array with disk information.
Return $aDiskArray
Case 2
; Return array with partition information.
Return $aPartitionArray
Case 3
; Return information of disk with system (Windows) partition.
Return $aSysDisk
Case 4
; Return information of system (Windows) partition.
Return $aSysPartition
Case Else
; If $iFlag was incorrect...
Return SetError(1, 2, "Error_IncorrectFlag")
EndSwitch

; If no data returned before...
SetError(1, 3, "Error_NoDataReturned")
EndFunc ;==>_GetDiskProperties

Func _GetGPUInfo($iFlag = 0)
Local Static $sName
Local Static $sMemory
Expand Down

0 comments on commit e6269e2

Please sign in to comment.