fix: wsl reg exception

This commit is contained in:
hstyi
2025-06-30 13:17:55 +08:00
committed by hstyi
parent b892d2fe13
commit 7c30933794

View File

@@ -21,10 +21,11 @@ object WSLSupport {
fun getDistributions(): List<WSLDistribution> { fun getDistributions(): List<WSLDistribution> {
if (isSupported.not()) return emptyList() if (isSupported.not()) return emptyList()
val distributions = mutableListOf<WSLDistribution>()
try {
val baseKeyPath = "Software\\Microsoft\\Windows\\CurrentVersion\\Lxss" val baseKeyPath = "Software\\Microsoft\\Windows\\CurrentVersion\\Lxss"
val guids = Advapi32Util.registryGetKeys(WinReg.HKEY_CURRENT_USER, baseKeyPath) val guids = Advapi32Util.registryGetKeys(WinReg.HKEY_CURRENT_USER, baseKeyPath)
val distributions = mutableListOf<WSLDistribution>()
for (guid in guids) { for (guid in guids) {
val key = baseKeyPath + "\\" + guid val key = baseKeyPath + "\\" + guid
@@ -50,6 +51,11 @@ object WSLSupport {
} }
} }
} }
} catch (e: Exception) {
if (log.isWarnEnabled) {
log.warn(e.message, e)
}
}
return distributions return distributions
} }