Files
Reims-Go/internal/app/qqgroup_windows.go
T
Nwflower 181c616909 feat(plugin,ui): consolidate builtin.core, enforce Guest Tools toggle, and add QQ group entry
- Merge essential builtins (driver, default theme, start prep, host workarounds) into always-on system plugin builtin.core, with state.json and arg-ledger migration plus app-scoped workaround settings honored by both GUI and CLI.
- Ensure disabling builtin.bridge.guest-tools stops the localhost bridge without being restarted by feature callers, fix guesttools.Server Start/Close race, and reflect the disabled state in VMPage and SettingsModal.
- Add QQ community group entry in About settings with Windows tencent:// protocol detection, cached invite redirect resolution, and copy-ID fallback.
- Update docs/plugin-architecture.md, Wails bindings, and i18n strings.
2026-11-29 09:54:51 -07:00

80 lines
1.6 KiB
Go

//go:build windows
package app
import (
"errors"
"fmt"
"os"
"strings"
"syscall"
"unsafe"
"golang.org/x/sys/windows/registry"
)
var (
qqShell32 = syscall.NewLazyDLL("shell32.dll")
qqProcShellExecW = qqShell32.NewProc("ShellExecuteW")
)
func hasQQProtocolHandler() bool {
type regLoc struct {
root registry.Key
path string
}
locs := []regLoc{
{registry.CURRENT_USER, `Software\Classes\tencent\shell\open\command`},
{registry.CLASSES_ROOT, `tencent\shell\open\command`},
}
for _, loc := range locs {
k, err := registry.OpenKey(loc.root, loc.path, registry.QUERY_VALUE)
if err != nil {
continue
}
val, _, err := k.GetStringValue("")
_ = k.Close()
if err != nil {
continue
}
exe := extractCommandExecutable(val)
if exe == "" {
continue
}
if expanded, err := registry.ExpandString(exe); err == nil && expanded != "" {
exe = expanded
}
if fi, err := os.Stat(exe); err == nil && !fi.IsDir() {
return true
}
}
return false
}
func launchQQProtocol(uri string) error {
trimmed := strings.TrimSpace(uri)
if !strings.HasPrefix(trimmed, "tencent://groupwpa/") {
return errors.New("refusing to open non-QQ-group protocol URL")
}
verb, err := syscall.UTF16PtrFromString("open")
if err != nil {
return err
}
target, err := syscall.UTF16PtrFromString(trimmed)
if err != nil {
return err
}
r, _, callErr := qqProcShellExecW.Call(
0,
uintptr(unsafe.Pointer(verb)),
uintptr(unsafe.Pointer(target)),
0,
0,
1, // SW_SHOWNORMAL
)
if r <= 32 {
return fmt.Errorf("ShellExecuteW tencent protocol failed (code %d): %w", r, callErr)
}
return nil
}