This is a creation in Article, where the information may have evolved or changed.
Example
Package Mainimport ("Github.com/lxn/win" "StrConv" "Syscall") Func _text (_str string) *uint16 {return syscall. Stringtoutf16ptr (_STR)}func _tostring (_n Int32) string {return StrConv. Itoa (int (_n))}func main () {var hwnd win. Hwndcxscreen: = win. GetSystemMetrics (win. Sm_cxscreen) Cyscreen: = win. GetSystemMetrics (win. Sm_cyscreen) win. MessageBox (hwnd, _text ("screen length-:" +_tostring (Cxscreen) + "width:" +_tostring (Cyscreen)), _text ("Message http://blog.csdn.net/ Songbohr "), win. MB_OK)}
The only thing that is there is a win this go module has a pit in the Phd.go
Func init () {//Librarylibpdhdll = Syscall. Mustloaddll ("Pdh.dll")//Functionspdh_addcounterw = Libpdhdll.mustfindproc ("Pdhaddcounterw") pdh_ Addenglishcounterw = Libpdhdll.mustfindproc ("pdhaddenglishcounterw")//Xxx:only supported on versions > Vista.pdh_ Closequery = Libpdhdll.mustfindproc ("pdhclosequery") Pdh_collectquerydata = Libpdhdll.mustfindproc (" Pdhcollectquerydata ") Pdh_getformattedcountervalue = Libpdhdll.mustfindproc (" Pdhgetformattedcountervalue ") pdh_ Getformattedcounterarrayw = Libpdhdll.mustfindproc ("pdhgetformattedcounterarrayw") Pdh_OpenQuery = Libpdhdll.mustfindproc ("Pdhopenquery") pdh_validatepathw = Libpdhdll.mustfindproc ("PDHVALIDATEPATHW")}
Pdhaddenglishcounterw This API is only supported in Vista or above, so if you run under XP, the address of the function will crash when it is loaded, temporary solution, violence comment out
Pdh_addenglishcounterw = Libpdhdll.mustfindproc ("pdhaddenglishcounterw")//Xxx:only supported on versions > Vista .
A richer example: Https://github.com/lxn/walk
Initial feeling with Go write win GUI, is a boring thing!
PostScript: Just searched the next Baidu, reproduced all did not indicate the source .... oh,shit!