A
A
amaterasu02020-10-12 17:02:38
go
amaterasu0, 2020-10-12 17:02:38

How to execute a DLL file using Golang?

I made a DLL file with go build -o testdll.dll -buildmode=c-shared dllGo.go

dllGo.go:

package main

import (
    "fmt"
    "os"

)


func TestCalc(a, b int) int {
    return a + b
}

func main() {
    fmt.Println(TestCalc(7, 9))
    f, err := os.Create("working.txt")
    if err != nil {
        fmt.Println(err)
    }
    f.Close()
}


How do I execute a DLL from main.go?

main.go:
package main

import (
    "fmt"
    "syscall"
)

func main() {
    
    h, err := syscall.LoadLibrary("testdll.dll")
    if err != nil {
        fmt.Println(err)
    }

}


What do I need to do to "run" testdll.dll?
Sorry for this might be a dumb question.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Philipp, 2020-10-12
@zoonman

https://golang.org/pkg/syscall/?GOOS=windows#examp...
https://github.com/golang/go/wiki/WindowsDLLs

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question