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.
[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
);
If the parameter is a plain number (positive or negative), it is sent as is.
If the parameter is a floating point number, it is rounded up and sent as a plain number.
If the parameter is a boolean, a number is sent: 1 for true, 0 for false.
If the parameter is null, 0 is sent.
If the parameter is a string, a pointer to a Unicode string is sent.
If the parameter is a DataBloc object, a pointer to its underlying data is sent.
If the parameter is any other object, a pointer to its IDispatch interface is sent. The reference count of the object is not increased.
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).
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.
This code displays a "Hello!" message box.
Interop.Call("User32.dll", "MessageBoxW", 0, "Hello!", "Example Message", 0);
| Object | Interop |
|---|---|
| Availability | Messenger Plus! Live 4.00 |