GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — lankir/console_windows.go at master · Matbe34/lankir

Expand file tree

/

console_windows.go

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
28 lines (25 loc) · 996 Bytes
/

console_windows.go

Copy path

File metadata and controls

28 lines (25 loc) · 996 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
//go:build windows
package main
import (
"os"
"syscall"
)
// attachParentConsole reattaches stdout/stderr to the parent console on
// Windows. The binary is built with -H windowsgui so double-clicking does not
// flash a console window, but CLI invocation from cmd/PowerShell still needs
// stdout to land somewhere visible. AttachConsole returns 0 if there is no
// parent console (e.g. launched from Explorer) — that is the GUI path and we
// silently skip rebinding.
func attachParentConsole() {
const attachParentProcess = ^uintptr(0) // -1, ATTACH_PARENT_PROCESS
kernel32 := syscall.NewLazyDLL("kernel32.dll")
if r1, _, _ := kernel32.NewProc("AttachConsole").Call(attachParentProcess); r1 == 0 {
return
}
if h, err := syscall.GetStdHandle(syscall.STD_OUTPUT_HANDLE); err == nil && h != 0 {
os.Stdout = os.NewFile(uintptr(h), "stdout")
}
if h, err := syscall.GetStdHandle(syscall.STD_ERROR_HANDLE); err == nil && h != 0 {
os.Stderr = os.NewFile(uintptr(h), "stderr")
}
}
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.