Files
order_site/apps/dcauth/registry_windows.go
T
yml2213 cb916d7750 feat(dcauth): 新增常驻托盘客户端与版本显示
Windows 改为单实例托盘常驻,协议唤起只弹一个确认窗口;补充 macOS 后台守护进程
与客户端版本显示。
2026-10-21 20:46:25 +08:00

45 lines
893 B
Go

//go:build windows
package main
import (
"os"
"os/exec"
"path/filepath"
)
func registerProtocol() {
executable, err := os.Executable()
if err != nil {
return
}
executable, err = filepath.Abs(executable)
if err != nil {
return
}
command := `"` + executable + `" "%1"`
runHiddenCommand(
"reg", "add", `HKCU\Software\Classes\dcauth`,
"/ve", "/d", "URL:DCAuth Protocol", "/f",
)
runHiddenCommand(
"reg", "add", `HKCU\Software\Classes\dcauth`,
"/v", "URL Protocol", "/d", "", "/f",
)
runHiddenCommand(
"reg", "add", `HKCU\Software\Classes\dcauth\DefaultIcon`,
"/ve", "/d", executable+",0", "/f",
)
runHiddenCommand(
"reg", "add", `HKCU\Software\Classes\dcauth\shell\open\command`,
"/ve", "/d", command, "/f",
)
}
func runHiddenCommand(name string, args ...string) {
command := exec.Command(name, args...)
hideCommandWindow(command)
_ = command.Run()
}