golang隐藏/显示window系统下的黑色命令窗(hide/show console)
阅读原文时间:2023年07月11日阅读:2

导入包
import "github.com/gonutz/ide/w32"

//隐藏console
func HideConsole(){

ShowConsoleAsync(w32.SW\_HIDE)  

}
//显示console
func ShowConsole(){
ShowConsoleAsync(w32.SW_SHOW)
}
//
func ShowConsoleAsync(commandShow uintptr){
console := w32.GetConsoleWindow()
if console != 0 {
_, consoleProcID := w32.GetWindowThreadProcessId(console)
if w32.GetCurrentProcessId() == consoleProcID {
w32.ShowWindowAsync(console, commandShow)
}
}
}

引用链接: https://stackoverflow.com/questions/23250505/how-do-i-create-an-executable-from-golang-that-doesnt-open-a-command-cmd-wind