有一段C++代码,怎么用go去调用者两个函数成功运行?(50元奖励,先到先得!)

golangking · · 963 次点击
两种方式,第一种自己封装,第二种调用golang.org/x/sys/windows ```go import ( "syscall" "unsafe" "golang.org/x/sys/windows" ) const ( ERROR_ALREADY_EXISTS = 183 ) var ( kernel32 = syscall.NewLazyDLL("kernel32.dll") procCreateMutex = kernel32.NewProc("CreateMutexW") ) func createMutex(name string) (uintptr, error) { ret, _, err := procCreateMutex.Call( 0, 0, uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(name))), ) switch int(err.(syscall.Errno)) { case 0: return ret, nil default: return ret, err } } func createMutexSys(name string) (windows.Handle, error) { return windows.CreateMutex(nil, true, syscall.StringToUTF16Ptr(m)) } ```
#2
更多评论
大佬们,帮我解决一下!
#1
确定一定要调用这个函数的话 cgo
#3