Messenger Plus! Live - Scripting Documentation

The Interop::Call function allows scripts to call functions located in external libraries. For example, it can be used to call functions from the Windows API.

Syntax

[number] Call(
    [string] DllName,
    [string] FunctionName,
    [var, optional] Param1,
    [var, optional] Param2,
    [var, optional] Param3,
    [var, optional] Param4,
    [var, optional] Param5,
    [var, optional] Param6,
    [var, optional] Param7,
    [var, optional] Param8,
    [var, optional] Param9,
    [var, optional] Param10,
    [var, optional] Param11,
    [var, optional] Param12
);

Parameters

DllName
[string] Path to the DLL file where the function to call is located. If multiple calls are made to the same DLL, the DLL is loaded only once and stays in memory until FreeDll is called or the script is terminated. The DLL file will be located by using the standard "LoadLibrary" mechanism described here. As no "current directory" is guaranteed for your script, you'll need to use MsgPlus.ScriptFilesPath to load a library from your script's directory.
FunctionName
[string] Name of the function as specified in the export table of the library. The function must use the __stdcall calling convention. See Remarks.
Param1
[var, optional] First parameter to send to the function, if any.
Here is how the data will be sent to the function depending on its type:
Param2
[var, optional] Second parameter to send to the function, if any. See Param1.
Param3
[var, optional] Third parameter to send to the function, if any. See Param1.
Param4
[var, optional] Fourth parameter to send to the function, if any. See Param1.
Param5
[var, optional] Fifth parameter to send to the function, if any. See Param1.
Param6
[var, optional] Sixth parameter to send to the function, if any. See Param1.
Param7
[var, optional] Seventh parameter to send to the function, if any. See Param1.
Param8
[var, optional] Eighth parameter to send to the function, if any. See Param1.
Param9
[var, optional] Ninth parameter to send to the function, if any. See Param1.
Param10
[var, optional] Tenth parameter to send to the function, if any. Accepted only in Messenger Plus! Live 4.21 and above. See Param1.
Param11
[var, optional] Eleventh parameter to send to the function, if any. Accepted only in Messenger Plus! Live 4.21 and above. See Param1.
Param12
[var, optional] Twelfth parameter to send to the function, if any. Accepted only in Messenger Plus! Live 4.21 and above. See Param1.

Return Value

A number, returned by the function. The meaning of this number depends on the function called.

This function typically fails for the following reasons:

Messenger Plus! Live 4.10 and above: an error is logged in the Script Debugging window when an exception is thrown during the call (often caused by incorrect parameters).

Remarks

Developers who use this function must be very careful about the functions they call and the parameters they accept. Here is a list of requirements for this function to succeed:

Most functions from the Windows API use the __stdcall convention, although you have to be careful to always use the "wide" version of each function. This means for example that to display a message box, you need to call "MessageBoxW". Calling a function with incorrect parameters will corrupt the Messenger memory space and eventually crash the program.

Messenger Plus! Live 4.10 and above: Messenger Plus! tries to detect bad calling conventions (when __stdcall was not used to declare the function that's being called) and logs the corresponding error in the Script Debugging window. Do NOT ignore these errors, they will cause instabilities and eventually crash Messenger in random places.

Example

This code displays a "Hello!" message box.

Interop.Call("User32.dll", "MessageBoxW", 0, "Hello!", "Example Message", 0);

Function Information

ObjectInterop
AvailabilityMessenger Plus! Live 4.00

See Also

Interop Object, DataBloc Object, Call2.