Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to call DLL class library in GOlang

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

How to call the DLL class library in GOlang? for this problem, this article introduces the corresponding analysis and solution in detail, hoping to help more partners who want to solve this problem to find a more simple and feasible method.

DLL prototype GetDllVersion function prototype: unsigned int GetDllVersion (void); get dll version information return value: DLL version information ((unsigned int), high byte main version information, low byte child version information = SetQianNiuPath function prototype: int SetQianNiuPath (const char * Path, unsigned int PathLen) Set Qianniu installation path (DLL does not save path) parameters: Path, Qianniu installation path (maximum length is not more than 255characters) PathLen Install your path length return value: 0 success-1 path problem-2 path folder does not exist = GO call DLLpackage mainimport ("fmt"syscall"unsafe") var (multiQianniuLogin = syscall.NewLazyDLL ("MultiQianniuLoginDll.dll") getDllVersion = multiQianniuLogin.NewProc ("GetDllVersion")) / / get the length pointer of the string func lenPtr (s string) uintptr { Return uintptr (len (s))} / / get the pointer to the number func intPtr (n int) uintptr {return uintptr (n)} / / get the pointer to the string func strPtr (s string) uintptr {return uintptr (unsafe.Pointer (syscall.StringBytePtr (s)} func main () {var ret uintptr var err error ret _, err = getDllVersion.Call () fmt.Printf ("% d% d\ n", byte (ret), uint8 (ret > > 8)) fmt.Println (err) path: = "C:\\ Program Files (x86)\\ AliWorkbench" _, err = setQianNiuPath.Call (strPtr (path), lenPtr (path)) fmt.Println (err)} execution result $GOARCH=386 go run main.go1.0The operation completed successfully.SetQianNiuPath C:\ Program Files (x86)\ AliWorkbench 35SetQianNiuPath result 0The operation completed successfully. This is the answer to the question about how to call the DLL class library in GOlang. I hope the above content can be of some help to you. If you still have a lot of doubts to be solved, you can follow the industry information channel to learn more about it.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report