Merge remote-tracking branch 'origin/pr/1081'

* origin/pr/1081:
  Revisit -no-console option for Windows
This commit is contained in:
Jakob Borg
2014-12-06 12:17:46 +01:00
3 changed files with 21 additions and 0 deletions

View File

@@ -24,3 +24,5 @@ func HideFile(path string) error {
func ShowFile(path string) error {
return nil
}
func HideConsole() {}

View File

@@ -48,3 +48,14 @@ func ShowFile(path string) error {
attrs &^= syscall.FILE_ATTRIBUTE_HIDDEN
return syscall.SetFileAttributes(p, attrs)
}
func HideConsole() {
getConsoleWindow := syscall.NewLazyDLL("kernel32.dll").NewProc("GetConsoleWindow")
showWindow := syscall.NewLazyDLL("user32.dll").NewProc("ShowWindow")
if getConsoleWindow.Find() == nil && showWindow.Find() == nil {
hwnd, _, _ := getConsoleWindow.Call()
if hwnd != 0 {
showWindow.Call(hwnd, 0)
}
}
}