Commit 4524e35c by 陶腾飞

2022-04-29

parent 4300faf8
...@@ -42,4 +42,6 @@ Get-PhysicalDisk ...@@ -42,4 +42,6 @@ Get-PhysicalDisk
2022年3月27日:加快CPU获取信息的速度 2022年3月27日:加快CPU获取信息的速度
2022年4月2日:跳过MSVD,增加对DDR4的判断 2022年4月2日:跳过MSVD,增加对DDR4的判断
\ No newline at end of file
2022年4月9日:修复DDR4的判断超过速率字段出现的场景导致无法判断DDR4的问题
No preview for this file type
...@@ -110,7 +110,6 @@ func getHardwareCPUForPS() (string, string, string, string) { ...@@ -110,7 +110,6 @@ func getHardwareCPUForPS() (string, string, string, string) {
return cpuCount, cpuName, cpuCores, cpuLogicalProcessors return cpuCount, cpuName, cpuCores, cpuLogicalProcessors
} }
func getHardwareMemoryForPS() ([]int, []string, []string, int) { func getHardwareMemoryForPS() ([]int, []string, []string, int) {
Capacity := make([]int, 2) Capacity := make([]int, 2)
Speed := make([]string, 2) Speed := make([]string, 2)
MemoryType := make([]string, 2) MemoryType := make([]string, 2)
...@@ -119,7 +118,7 @@ func getHardwareMemoryForPS() ([]int, []string, []string, int) { ...@@ -119,7 +118,7 @@ func getHardwareMemoryForPS() ([]int, []string, []string, int) {
menUN, _ := PSCommandOutputNoSplit("Get-WmiObject -Class Win32_PhysicalMemory -Property Capacity,Speed,MemoryType") menUN, _ := PSCommandOutputNoSplit("Get-WmiObject -Class Win32_PhysicalMemory -Property Capacity,Speed,MemoryType")
for _, line := range strings.Split(menUN, "\n") { for _, line := range strings.Split(menUN, "\n") {
if strings.Index(line, "Capacity") != -1 { if strings.Contains(line, "Capacity") {
mi := strings.TrimSpace(strings.Split(line, ":")[1]) mi := strings.TrimSpace(strings.Split(line, ":")[1])
m, _ := strconv.ParseInt(mi, 10, 64) m, _ := strconv.ParseInt(mi, 10, 64)
...@@ -130,7 +129,7 @@ func getHardwareMemoryForPS() ([]int, []string, []string, int) { ...@@ -130,7 +129,7 @@ func getHardwareMemoryForPS() ([]int, []string, []string, int) {
} }
c++ c++
} else if strings.Index(line, "Speed") != -1 { } else if strings.Contains(line, "Speed") {
m := strings.TrimSpace(strings.Split(line, ":")[1]) m := strings.TrimSpace(strings.Split(line, ":")[1])
if j >= 2 { if j >= 2 {
Speed = append(Speed, m) Speed = append(Speed, m)
...@@ -138,9 +137,13 @@ func getHardwareMemoryForPS() ([]int, []string, []string, int) { ...@@ -138,9 +137,13 @@ func getHardwareMemoryForPS() ([]int, []string, []string, int) {
Speed[j] = m Speed[j] = m
} }
c++ c++
} else if strings.Index(line, "MemoryType") != -1 { } else if strings.Contains(line, "MemoryType") {
m := strings.TrimSpace(strings.Split(line, ":")[1]) m := strings.TrimSpace(strings.Split(line, ":")[1])
switch m { switch m {
// 其实吧,是有可能的
case "0":
m = "0"
case "21": case "21":
m = "DDR2" m = "DDR2"
case "22": case "22":
...@@ -149,12 +152,6 @@ func getHardwareMemoryForPS() ([]int, []string, []string, int) { ...@@ -149,12 +152,6 @@ func getHardwareMemoryForPS() ([]int, []string, []string, int) {
m = "DDR3" m = "DDR3"
case "26": case "26":
m = "DDR4" m = "DDR4"
case "0":
if i, err := strconv.Atoi(Speed[j]); err != nil {
m = ""
} else if i >= 2133 {
m = "DDR4"
}
default: default:
m = "" m = ""
} }
...@@ -170,6 +167,13 @@ func getHardwareMemoryForPS() ([]int, []string, []string, int) { ...@@ -170,6 +167,13 @@ func getHardwareMemoryForPS() ([]int, []string, []string, int) {
} }
} }
for i, line := range MemoryType {
if line == "" || line == "0" {
if speed, err := strconv.Atoi(Speed[i]); err == nil && speed >= 2133 {
MemoryType[i] = "DDR4"
}
}
}
return Capacity, Speed, MemoryType, j - 1 return Capacity, Speed, MemoryType, j - 1
} }
func getHardwareHardDiskForPS(mini bool) ([]string, []int64, []string, int) { func getHardwareHardDiskForPS(mini bool) ([]string, []int64, []string, int) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment