I'm looking for an example code how import a function from a dll written in C. equivalent to DllImport
of C#.NET
. It's possible?
I'm using windows.
any help is appreciated. thanks in advance.
相关问题
- Multiple sockets for clients to connect to
- How to know full paths to DLL's from .csproj f
- What is the best way to do a search in a large fil
- glDrawElements only draws half a quad
- Index of single bit in long integer (in C) [duplic
Use the same method that the Windows port of Go does. See the source code for the Windows implementation of the Go syscall package. Also, take a look at the source code for the experimental Go exp/wingui package
You want to use cgo. Here's an introduction.
There are a few ways to do it.
The cgo way allows you to call the function this way:
It will call libraries basically by "linking" against the library. You can put C code into Go and import the regular C way.
There are more methods such as syscall
...
There is this useful github page which describes the process of using a DLL: https://github.com/golang/go/wiki/WindowsDLLs
There are three basic ways to do it.