...
This commit is contained in:
@@ -18,4 +18,29 @@ object HardwareDetector {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fun getWindowsCpuName(): String {
|
||||
return try {
|
||||
val process = Runtime.getRuntime().exec("wmic cpu get name")
|
||||
val reader = process.inputStream.bufferedReader()
|
||||
reader.readLine() // 첫 줄(Name) 건너뛰기
|
||||
reader.readLine()?.trim() ?: "Unknown CPU"
|
||||
} catch (e: Exception) {
|
||||
"Error detecting CPU"
|
||||
}
|
||||
}
|
||||
|
||||
fun getMacCpuName(): String {
|
||||
return try {
|
||||
val process = Runtime.getRuntime().exec("sysctl -n machdep.cpu.brand_string")
|
||||
process.inputStream.bufferedReader().readLine()?.trim() ?: "Unknown Apple Silicon"
|
||||
} catch (e: Exception) {
|
||||
"Error detecting CPU"
|
||||
}
|
||||
}
|
||||
fun getCpuName(): String {
|
||||
val os = System.getProperty("os.name").lowercase()
|
||||
return if (os.contains("win")) getWindowsCpuName() else getMacCpuName()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user