From 551aafc0b46bcc4750977584d0a83ea1e87aa8df Mon Sep 17 00:00:00 2001 From: Gopal Adhikari Date: Sat, 28 Apr 2018 17:42:59 -0400 Subject: [PATCH] Fix some grammatical errors and clarify words --- WindowsDLLs.md | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/WindowsDLLs.md b/WindowsDLLs.md index 2de7986c..e3df9ff5 100644 --- a/WindowsDLLs.md +++ b/WindowsDLLs.md @@ -1,10 +1,10 @@ # Calling a Windows DLL -There are a few ways to call "C" code from inside Go +Go allows you to call native Windows function in several different ways. -First way: Dynamically load a dll, then call a method on it. You can call the method via "syscallXX" (the XX is number of parameters, but if it has few than that, like if you need seven parameter, then syscall9 will still work, you just tell it the number of arguments is 7). +1. Dynamically load a DLL, then call a function in it. You can call the function via `SyscallX` (where X is the number of parameters. If the function has fewer parameters than that, for example passing 7 arguments to a function that accepts 9, `Syscall9` will still work, you just need to specify 7 as your second argument to `Syscall9`). -A sample program that calls Windows DLLs from Go: +A sample Go program that calls a Windows DLL function using this method: ```go package main @@ -94,7 +94,7 @@ func init() { ``` -Second way is via syscall.NewProc (etc.) instead of syscall.GetProcAddress. These are basically some helper methods over the syscall ones, you saw above, and are available in Windows only: http://golang.org/src/pkg/syscall/dll_windows.go +2. Using syscall.NewProc instead of syscall.GetProcAddress. These are basically some helper methods over the syscall ones, you saw above, and are available in Windows only: http://golang.org/src/pkg/syscall/dll_windows.go ```go package main @@ -119,9 +119,7 @@ func main() { } ``` -A third way would be to call into libraries basically by "linking" against the library, using the "[[cgo]]" method (this way works in Linux and Windows): - -This way would look something like this +3. By "linking" against the library, using the "[[cgo]]" method (this way works in Linux and Windows). Example: ```go import ("C")