0

I want to use wmi to get the GPU info in a program written in Go.I know use the https://godoc.org/github.com/StackExchange/wmi can do it,and here is a function named "func Query".But, i don't know how to edit the "query string".Somebody can help me ? Thanks!

kostix
  • 51,517
  • 14
  • 93
  • 176
DK AL
  • 1
  • 2
  • This has nothing to do with Go. Just [do this](https://www.google.com/search?q=WMI+GPU). – kostix May 25 '18 at 11:28
  • BTW the 1st resource there suggests using [this](https://archive.codeplex.com/?p=wmie) which claims to support «utomatic generation of WQL query for the selected Class/Instance.», so basically you may run that tool, do a few mouse clicks then copy and paste the query it will have generated for you. – kostix May 25 '18 at 11:31

1 Answers1

0
import (
    "github.com/StackExchange/wmi"
)

type gpuInfo struct {
    Name string
}

func getGPUInfo() {
    var gpuinfo []gpuInfo
    err := wmi.Query("Select * from Win32_VideoController", &gpuinfo)
    if err != nil {
        return
    }
    fmt.Printf("gpu:",gpuinfo[0].Name)
}
jnovack
  • 7,629
  • 2
  • 26
  • 40
DK AL
  • 1
  • 2