1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00
v/vlib/dl/dl_windows.c.v

30 lines
702 B
V
Raw Normal View History

2020-04-28 12:53:55 +03:00
module dl
pub const (
RTLD_NOW = 0
RTLD_LAZY = 0
2020-04-29 22:01:19 +03:00
DL_EXT = '.dll'
2020-04-28 12:53:55 +03:00
)
2020-04-29 22:01:19 +03:00
fn C.LoadLibrary(libfilename C.LPCWSTR) voidptr
2020-04-28 12:53:55 +03:00
2020-04-29 22:01:19 +03:00
fn C.GetProcAddress(handle voidptr, procname C.LPCSTR) voidptr
fn C.FreeLibrary(handle voidptr) bool
// open loads a given module into the address space of the calling process.
2020-04-28 12:53:55 +03:00
pub fn open(filename string, flags int) voidptr {
2020-04-29 22:01:19 +03:00
res := C.LoadLibrary(filename.to_wide())
2020-04-28 12:53:55 +03:00
return res
}
2020-04-29 22:01:19 +03:00
// close frees the loaded a given module.
pub fn close(handle voidptr) bool {
return C.FreeLibrary(handle)
}
// sym returns an address of an exported function or variable from a given module.
2020-04-28 12:53:55 +03:00
pub fn sym(handle voidptr, symbol string) voidptr {
return C.GetProcAddress(handle, symbol.str)
}