The go language allows Windows to make sounds or play music as an example: Alert alert sounds
(This is written by my group member for help, if you need to know the calling principle or process or more of the Go language call Win32API, Dabigatran: 218160862, the answer I told you)
Package Main
Func Main () {
WinSound ()
}
//Golang Let Windows warn the sound todo needs to perfect play MP3 and the like
Func WinSound () {
Funindllfile, err: = Syscall. LoadLibrary ("Winmm.dll")//DLL file called
If err! = Nil {
print ("Cant not call:syscall. LoadLibrary, ErrorInfo: "+ Err. Error ())
}
Defer syscall. FreeLibrary (Funindllfile)
The functions inside the called DLL are:
Funname: = "PlaySound"
//Register a long string of call codes, simplifying to _win32fun variables.
Win32fun, err: = Syscall. GetProcAddress (Syscall. Handle (Funindllfile), funname)
//Through Syscall. SYSCALL6 () to call the Win32 XXX function, because the XXX function has 3 parameters, so need to take Syscall6 to put down. The last 3 parameters, set to 0
_, Err = Syscall. SYSCALL6 (
UIntPtr (Win32fun), //called function name
3, //Indicates the number of arguments to the function
UIntPtr (unsafe. Pointer (Syscall. Stringtoutf16ptr ("alert")),//parameter 1 of the function. function names can be searched by MSDN for parameter meanings
// Systemstart
uintptr (0), //Parameter 2 of the function.
UIntPtr (0), //Parameter 3 of the function.
0,
0,
0)
}
Go language lets windows make a sound or play music