mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
29 lines
687 B
V
29 lines
687 B
V
module dl
|
|
|
|
pub const (
|
|
RTLD_NOW = 0
|
|
DL_EXT = '.dll'
|
|
)
|
|
|
|
fn C.LoadLibrary(libfilename C.LPCWSTR) voidptr
|
|
|
|
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.
|
|
pub fn open(filename string, flags int) voidptr {
|
|
res := C.LoadLibrary(filename.to_wide())
|
|
return res
|
|
}
|
|
|
|
// 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.
|
|
pub fn sym(handle voidptr, symbol string) voidptr {
|
|
return C.GetProcAddress(handle, symbol.str)
|
|
}
|