Files
Local-Cursor/internal/winexec/winexec_windows.go
FuDie0915 db73cf5a39 chore: import Local-Cursor v1.1.8 source snapshot
Includes the current working directory changes. Historical commits and release binaries are excluded to limit Gitea storage.
Source base: d7515973fbfd6dd2001fa156c483455b8081c7cb
2026-11-10 01:24:28 +08:00

27 lines
844 B
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
//go:build windows
// Package winexec 提供 Windows 下隐藏控制台窗口的子进程启动。
// GUI 程序直接 exec.Command 会在每次调用时闪现控制台窗口。
package winexec
import (
"os/exec"
"syscall"
)
// creationFlags 组合 CREATE_NO_WINDOW,避免子进程弹出控制台。
const creationFlags = 0x08000000
// Command 等价于 exec.Command,但在 Windows 上隐藏子进程窗口。
func Command(name string, args ...string) *exec.Cmd {
cmd := exec.Command(name, args...)
cmd.SysProcAttr = &syscall.SysProcAttr{HideWindow: true, CreationFlags: creationFlags}
return cmd
}
// Hide 配置一个已有的 exec.Cmd 隐藏窗口(用于 CommandContext 等场景)。
func Hide(cmd *exec.Cmd) *exec.Cmd {
cmd.SysProcAttr = &syscall.SysProcAttr{HideWindow: true, CreationFlags: creationFlags}
return cmd
}