hg888皇冠手机登录

Go完成Windows彩色命令行输出

六月 21st, 2019  |  www.hg888.com

func ColorPrintln(s string, i int) {
    kernel32 := syscall.NewLazyDLL("kernel32.dll")
    proc := kernel32.NewProc("SetConsoleTextAttribute")
    handle, _, _ := proc.Call(uintptr(syscall.Stdout), uintptr(i)) //12 Red light

    fmt.Println(s)

    handle, _, _ = proc.Call(uintptr(syscall.Stdout), uintptr(7)) //White dark
    CloseHandle := kernel32.NewProc("CloseHandle")
    CloseHandle.Call(handle)
}
//该片段来自于http://outofmemory.cn
标签:, , , ,

Your Comments

近期评论

    功能


    网站地图xml地图