我试试这个
name := C.CString("vds")
C.OpenService(scm, (name), C.DWORD(C.SC_MANAGER_ALL_ACCESS))
但它不会编译
.\test.go:28: cannot use name (type *C.char) as type *C.CHAR in argument to _Cfunc_OpenService
我尝试寻找类似的东西(例如sqlite),但他们似乎使用同样的习惯用法,但它编译
答案 0 :(得分:0)
尝试明确地投射它:
name := C.CString("vds")
C.OpenService(scm, (*C.CHAR)(unsafe.Pointer(name)), C>DWORD(C.SC_MANAGER_ALL_ACCESS))