Maptitude GISDK Help |
Calls a function in a Dynamic Link Library (DLL).
Optional options array added in Version 5.0.
ret_val = CallDllFunction(string dll_name, string func_name, string ret_type, array args [, array options])
Argument |
Contents |
dll_name |
The name of the Dynamic Link Library (DLL) |
func_name |
The name of the function to call in the DLL |
ret_type |
The type of value to return: "int", "double", "string" or null |
args |
An array of arguments to pass to the function |
Option |
Type |
Contents |
StdCall |
Boolean |
If "true" assumes the _stdcall calling convention, where arguments are passed on the stack and the called function is responsible for removing them off the stack; default is "false" |
FastCall |
Boolean |
If "true" assumes the _fastcall calling convention, where some arguments are passed in registers and the called function is responsible for popping other arguments off the stack; default is "false" |
Cdecl |
Boolean |
Assumes the _cdecl calling convention, where the arguments are passed on the stack and the and the calling function is responsible for removing them off the stack; defaultis "true" |
A value of the type specified by ret_type.
The options array is an optional argument.
You can replace calls to CallDllFunction() by using the new, closely related LoadLibrary() function.
Each member of args must be either an integer, double, string, null, or array of longs or doubles (all the same type).
Values in the arrays will be replaced by their values after the call.
Any args value that will be filled in must be created first.
In 64-bit programs the calling convention option is ignored, since all 64-bit programs use the equivalent of the FastCall calling convention.
In a 32-bit environment, all Standard Windows API functions use StdCall.
Arguments can be passed in one of two ways:
New style: each member of the array is a pair: {type, argument}, where type is a string describing the argument: "short", "long", "float", "double" or "string", meaning the argument is of that type. The type can be succeeded by one or more "*", meaning the argument is an array of that type, two stars mean it's an array of arrays (all of same length), etc. The type can be preceded by "const ", see below.
Old style: each member of args must be either an integer, double, string, null, or array of longs or doubles (all same type) - corresponding to long, double, char*, null, long* or double*.
The values in the arrays will be replaced by their values after the call, except when they are of type "const".
// Initialize an string
str = null
for i = 1 to 200 do
str = str + " "
end
// Windows API uses StdCall
opts = {{"StdCall", "True"}}
// Call a function in kernel32.dll
Ret = CallDllFunction("kernel32", "GetSystemDirectoryA", "int", {str, 200}, opts)
ShowArray({Ret, str})
Error Type |
Meaning |
Error |
An invalid parameter was specified |
NotFound |
The DLL or one of its required components was not found or could not be loaded |
Function |
Summary |
Starts a Windows program |
|
Open a document, executable, or URL with the appropriate program |
|
Loads a DLL and returns a handle that can be used in function calls |
©2025 Caliper Corporation | www.caliper.com |