Files
Odin/code/demo.odin
T
2016-12-09 00:07:08 +00:00

32 lines
631 B
Odin

#import "win32.odin"
#import "fmt.odin"
main :: proc() {
get_proc :: proc(lib: win32.HMODULE, name: string) -> proc() {
buf: [4096]byte
copy(buf[:], name as []byte)
proc_handle := win32.GetProcAddress(lib, ^buf[0])
return proc_handle as proc()
}
lib := win32.LoadLibraryA(("example.dll\x00" as string).data)
if lib == nil {
fmt.println("Could not load library")
return
}
defer win32.FreeLibrary(lib)
proc_handle := get_proc(lib, "some_thing")
if proc_handle == nil {
fmt.println("Could not load 'some_thing'")
return
}
some_thing := (proc_handle as proc())
fmt.println(some_thing)
some_thing()
}