Salesforce

CallDLL (Magic xpa 3.x)

« Go Back

Information

 
Created ByKnowledge Migration User
Approval Process StatusPublished
Objective
Description

CallDLL (Magic xpa 3.x)

Enables a dynamic and direct call to a DLL from within Magic xpa.

Syntax:

CallDLL('modulename.functionname', 'argument type string', arg1, arg2, ...)

Parameters:

modulename.functionname – The module and function names from the DLL.

Argument type string – A string in which each character represents the type of argument. The last character represents the type of the return value of the function.
Click here for a list of argument types.

Arg1, Arg2, ... – The function arguments from the DLL.

Returns:

The return value of the function in the DLL.

Only the return value will be returned to Magic xpa. Any modifications made to the variables sent will not be reflected in Magic xpa.

Examples:

CallDLL('mydll.lmath','1L44', Action, A, B) where the C function is: long lmath (char action, long *a, long b) gives the return value of the lmath function in the DLL.

CallDLL('mydll.add_str', 'AAA', A, B) where the C function is: char *add_str (char *a, char *b) gives the return value of the add_str function in the DLL.

Note:

  1. A lot of DLLs require the "handle" of a window. This is an identification number for each existing window. It's easy to supply this to your CallDLL, using the Magic xpa WinHWND() function. It takes one parameter, the generation, so calling it for the current task's window will always be WinHWND(0).

  2. If the DLL function expects to receive complex structures, it may be easier to use .NET code to call the DLL.

    For example, for a function which receives and returns a string buffer (BStr), then instead of having: Update A with CallDLL('mydll.myfunc','AA',B) where A and B are Alpha variables, you can have the following Invoke .NET operation with A as a return value and B as the argument:

using System;

using System.Runtime.InteropServices;

public static class Snippet

{

public static System.String func(ref System.String input)

{

return myfunc(input);

}

[DllImport("mydll.dll", CharSet = CharSet.Auto)]

[return: MarshalAs(UnmanagedType.BStr)]

public static extern string myfunc([MarshalAs(UnmanagedType.BStr)] string Interface);

}

See also:

How Do I Call a DLL Function?

The Online and Rich Client Samples projects (program EL09 and REL09)

Reference
Attachment 
Attachment