欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

golang隐藏/显示window系统下的黑色命令窗(hide/show console)

程序员文章站 2022-04-13 22:28:28
导入包import "github.com/gonutz/ide/w32" //隐藏consolefunc HideConsole(){ ShowConsoleAsync(w32.SW_HIDE)}//显示consolefunc ShowConsole(){ ShowConsoleAsync(w32... ......

 

导入包
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://*.com/questions/23250505/how-do-i-create-an-executable-from-golang-that-doesnt-open-a-command-cmd-wind