Git Product home page Git Product logo

dll-call-in-golang's Introduction

DLL-call-in-Golang

How to call Windows DLL using LoadLibrary in Golang

First, of course you need to create a simple DLL. Follow the steps by PauloGP's github : https://gist.github.com/paulogp/1345006

I also put the .zip file that contains the project code for my DLL. You just need to open the project and build it to create the .DLL.
For simplicity, i also attach together the 64-bit square.dll which created earlier.

Make sure you build for 64-bit if your Golang is running in 64-bit machine.
Once you have the .DLL, copy it and paste under the same folder where your Golang code will reside.

In this example, i create a simple Golang function in which it will load the DLL and finally call the function inside the DLL. Here, the function name is "dll_math_example". It is as simple function where it takes 4 input parameters of type int to be added together.

In line 20, u can see i used "syscall.Syscall9(uintptr(proc), 0, 2, 2, 2, 2, 0, 0, 0, 0, 0)". This will invoke the function with 4 inputs. So, the operation will be 2+2+2+2, yields a result of 8.

dll-call-in-golang's People

Contributors

zakibakar75 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.