| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 | 
							- // Copyright (C) 2014 The Syncthing Authors.
 
- //
 
- // This Source Code Form is subject to the terms of the Mozilla Public
 
- // License, v. 2.0. If a copy of the MPL was not distributed with this file,
 
- // You can obtain one at http://mozilla.org/MPL/2.0/.
 
- // +build windows
 
- package osutil
 
- import "syscall"
 
- func HideFile(path string) error {
 
- 	p, err := syscall.UTF16PtrFromString(path)
 
- 	if err != nil {
 
- 		return err
 
- 	}
 
- 	attrs, err := syscall.GetFileAttributes(p)
 
- 	if err != nil {
 
- 		return err
 
- 	}
 
- 	attrs |= syscall.FILE_ATTRIBUTE_HIDDEN
 
- 	return syscall.SetFileAttributes(p, attrs)
 
- }
 
- func ShowFile(path string) error {
 
- 	p, err := syscall.UTF16PtrFromString(path)
 
- 	if err != nil {
 
- 		return err
 
- 	}
 
- 	attrs, err := syscall.GetFileAttributes(p)
 
- 	if err != nil {
 
- 		return err
 
- 	}
 
- 	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)
 
- 		}
 
- 	}
 
- }
 
 
  |