init commit
This commit is contained in:
30
core/settings_windows.go
Normal file
30
core/settings_windows.go
Normal file
@@ -0,0 +1,30 @@
|
||||
//go:build windows
|
||||
|
||||
package core
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"golang.org/x/sys/windows/registry"
|
||||
)
|
||||
|
||||
const regRunKey = `SOFTWARE\Microsoft\Windows\CurrentVersion\Run`
|
||||
|
||||
// ApplyStartupRegistry adds or removes the app from Windows startup registry.
|
||||
func (s *AppSettings) ApplyStartupRegistry() {
|
||||
key, err := registry.OpenKey(registry.CURRENT_USER, regRunKey, registry.SET_VALUE)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
defer key.Close()
|
||||
|
||||
if s.RunOnStartup {
|
||||
exePath, err := os.Executable()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
_ = key.SetStringValue("kettuRay", `"`+exePath+`"`)
|
||||
} else {
|
||||
_ = key.DeleteValue("kettuRay")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user