[Fix] Firefox inspecting logic on Windows (#502)

* Fix (firefox_windows.go): Release resources

It seems `defer` keyword is using to release and close some resources.
It should be added to `getFirefoxPath` function.

Signed-off-by: Dragon1573 <49941141+Dragon1573@users.noreply.github.com>

* Fix (firefox_windows.go): Registry path

For Mozilla Firefox Stable edition, it's incorrect in `getFirefoxPath` function.

Signed-off-by: Dragon1573 <49941141+Dragon1573@users.noreply.github.com>

* Fix (firefox_windows.go): Registry Value

Signed-off-by: Dragon1573 <49941141+Dragon1573@users.noreply.github.com>

* Update (firefox_windows.go): Reformat code

Advices from GitHub Workflows, try fix this using GitHub Web.

---------

Signed-off-by: Dragon1573 <49941141+Dragon1573@users.noreply.github.com>
This commit is contained in:
是蓝兔哟~ 2023-12-24 20:37:17 +08:00 committed by GitHub
parent d7fb6e1045
commit 8bca0f17ee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 2 deletions

View File

@ -17,11 +17,13 @@ func getFirefoxPath() string {
k, err := registry.OpenKey(
registry.LOCAL_MACHINE,
`Software\Mozilla\`+flavor+` `+versionString+`\bin`,
`Software\Mozilla\`+flavor+`\`+versionString+`\Main`,
registry.QUERY_VALUE)
if err != nil {
Shutdown(fmt.Errorf("Error reading Windows registry: %w", err))
}
defer k.Close()
path, _, err := k.GetStringValue("PathToExe")
if err != nil {
Shutdown(fmt.Errorf("Error reading Windows registry: %w", err))
@ -42,7 +44,7 @@ func getWindowsFirefoxVersionString() string {
}
defer k.Close()
versionString, _, err := k.GetStringValue("")
versionString, _, err := k.GetStringValue("CurrentVersion")
if err != nil {
Shutdown(fmt.Errorf("Error reading Windows registry: %w", err))
}