Library.constructor([lib]) constructor
The Library constructor creates a new Library instance, that represents a Windows DLL.
Once the Library is loaded, its exported symbols are accessible using the returned Library instance.
Parameters
[lib]
An optional string
representing the Windows dynamic library to load.
The string
can be a full path or a DLL name in the current path.
- When the
lib
parameter is omitted, the C runtime library will be loaded.
- DLL embedded in the current compiled executable are loaded seamlessly.
- If the provided library cannot be loaded, the constructor returns
nil
(use sys.error to get the error message).
Example
local c = require "c"
-- loads the C runtime library
local crt = c.Library()
-- Use the Library instance to define the C function "printf()"
crt.puts = "(Z)"
-- Calls the just defined C function
crt.puts("Hello LuaRT")