importDynamic (Utility)

Imports a function from a dynamic library.

Arguments

paramStructure
is a structure of names and types of the function parameters.
resultStructure
is a structure with name and type of the function return value.
libraryName
is a string.
functionName
is a string.

Return values

None

Example

Note: this code is Windows-specific and will not work in the web interpreter.

{ lpFileName:""; dwDesiredAccess: 0i32; dwShareMode: 0i32; lpSecurityAttributes: 0nx; dwCreationDisposition: 0i32; dwFlagsAndAttributes: 0i32; hTemplateFile: 0nx;} { hFile: 0nx; } "Kernel32" "CreateFileA" importDynamic { hFile: 0nx; lpFileSize: 0nx; } { result: 0n32; } "Kernel32" "GetFileSizeEx" importDynamic { hFile: 0nx;} () "Kernel32" "CloseHandle" importDynamic loadFile: [ name:; NULL: 0nx; GENERIC_READ: 0x80000000; FILE_SHARE_READ: 0x00000001; OPEN_EXISTING: 3i32; fileHandle: name GENERIC_READ FILE_SHARE_READ NULL OPEN_EXISTING 0i32 NULL CreateFileA; fileHandle 0xFFFFFFFFnx = [ "Error" print LF print ] [ fileSizePointer: 8n32 allocateMemory; fileSize: 0n32 fileHandle fileSizePointer GetFileSizeEx drop fileSizePointer readMemory; "File size is " print fileSize print LF print fileSizePointer freeMemory fileHandle CloseHandle ] if ] func; "myfilename" loadFile