Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
catHardware
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
陶腾飞
catHardware
Commits
4524e35c
Commit
4524e35c
authored
Apr 09, 2022
by
陶腾飞
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
2022-04-29
parent
4300faf8
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
12 deletions
+17
-12
README.md
+3
-2
catHardware.exe
+0
-0
main.go
+14
-10
No files found.
README.md
View file @
4524e35c
...
...
@@ -42,4 +42,6 @@ Get-PhysicalDisk
2022年3月27日:加快CPU获取信息的速度
2022年4月2日:跳过MSVD,增加对DDR4的判断
\ No newline at end of file
2022年4月2日:跳过MSVD,增加对DDR4的判断
2022年4月9日:修复DDR4的判断超过速率字段出现的场景导致无法判断DDR4的问题
catHardware.exe
View file @
4524e35c
No preview for this file type
main.go
View file @
4524e35c
...
...
@@ -110,7 +110,6 @@ func getHardwareCPUForPS() (string, string, string, string) {
return
cpuCount
,
cpuName
,
cpuCores
,
cpuLogicalProcessors
}
func
getHardwareMemoryForPS
()
([]
int
,
[]
string
,
[]
string
,
int
)
{
Capacity
:=
make
([]
int
,
2
)
Speed
:=
make
([]
string
,
2
)
MemoryType
:=
make
([]
string
,
2
)
...
...
@@ -119,7 +118,7 @@ func getHardwareMemoryForPS() ([]int, []string, []string, int) {
menUN
,
_
:=
PSCommandOutputNoSplit
(
"Get-WmiObject -Class Win32_PhysicalMemory -Property Capacity,Speed,MemoryType"
)
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
])
m
,
_
:=
strconv
.
ParseInt
(
mi
,
10
,
64
)
...
...
@@ -130,7 +129,7 @@ func getHardwareMemoryForPS() ([]int, []string, []string, int) {
}
c
++
}
else
if
strings
.
Index
(
line
,
"Speed"
)
!=
-
1
{
}
else
if
strings
.
Contains
(
line
,
"Speed"
)
{
m
:=
strings
.
TrimSpace
(
strings
.
Split
(
line
,
":"
)[
1
])
if
j
>=
2
{
Speed
=
append
(
Speed
,
m
)
...
...
@@ -138,9 +137,13 @@ func getHardwareMemoryForPS() ([]int, []string, []string, int) {
Speed
[
j
]
=
m
}
c
++
}
else
if
strings
.
Index
(
line
,
"MemoryType"
)
!=
-
1
{
}
else
if
strings
.
Contains
(
line
,
"MemoryType"
)
{
m
:=
strings
.
TrimSpace
(
strings
.
Split
(
line
,
":"
)[
1
])
switch
m
{
// 其实吧,是有可能的
case
"0"
:
m
=
"0"
case
"21"
:
m
=
"DDR2"
case
"22"
:
...
...
@@ -149,12 +152,6 @@ func getHardwareMemoryForPS() ([]int, []string, []string, int) {
m
=
"DDR3"
case
"26"
:
m
=
"DDR4"
case
"0"
:
if
i
,
err
:=
strconv
.
Atoi
(
Speed
[
j
]);
err
!=
nil
{
m
=
""
}
else
if
i
>=
2133
{
m
=
"DDR4"
}
default
:
m
=
""
}
...
...
@@ -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
}
func
getHardwareHardDiskForPS
(
mini
bool
)
([]
string
,
[]
int64
,
[]
string
,
int
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment