This commit is contained in:
2026-03-27 17:08:12 +09:00
parent 0479d5777a
commit 9803b27741
2 changed files with 56 additions and 2 deletions
+25
View File
@@ -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()
}
}