Maptitude GISDK Help

CallDllFunction()

Summary

Calls a function in a Dynamic Link Library (DLL).

 

Changes

Optional options array added in Version 5.0.

 

Syntax

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"

 

Returns

A value of the type specified by ret_type.

 

Notes

Notes on the New Argument Convention

Arguments can be passed in one of two ways:

  1. 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.

  2. 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".

 

Example

// 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 Codes

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

 

See Also

Function Summary
LaunchProgram() Starts a Windows program
LaunchDocument() Open a document, executable, or URL with the appropriate program
LoadLibrary() Loads a DLL and returns a handle that can be used in function calls

 

 

©2025 Caliper Corporation www.caliper.com