%DLL_NETCALL
|
|
|
NSupported in Synergy .NET
|
value = %DLL_NETCALL(dll_handle, [convention], func_name[, arg_array])
Return value
value
The value of the DLL function as an integer data type. (^VAL)
Arguments
dll_handle
The handle of the DLL, as returned from %DLL_OPEN. (i)
convention
One of the following calling conventions: (n)
Use C calling convention.
Use __fastcall calling convention.
Use __stdcall calling convention.
Use WINAPI calling convention.
func_name
The name of the function to be called within the DLL. (a)
arg_array
(optional) A dynamic array of objects ([#]@*) used to pass data types to the function in the DLL.
Rather than using %DLL_NETCALL, we recommend that you use the DllImport attribute to call native code from a managed application. You can specify the DllImport attribute on a method to denote an external method call in a COM or Win32 DLL and set the parameter values as needed. See Attributes (.NET) for information on using an attribute. See the second example in Examples for a code sample that uses DllImport. |
The %DLL_NETCALL function calls a subroutine or function in a DLL from Synergy .NET.
Before invoking %DLL_NETCALL, check the documentation for your DLL to find out how the function is declared, which data type the function will return, which calling convention to use, and which arguments are necessary. If you call a DLL subroutine with improper arguments, the result is undefined. The Declaring variables based on argument expected table and Declaring variables based on return value table provide additional information about the return value of the DLL function and the arguments expected by the DLL function.
To create the elements in arg_array, use code similar to the following:
Arg_array = new Object[3] Arg_array[1] = (object)myavar Arg_array[2] = (object)myint Arg_array[3] = (object)^addr(myavar)
and so forth.
main record producer ,a6 ,'999' application ,a6 ,'RUN9' users ,i4 ,0 sys_err ,i4 ,0 dll_hdl ,i4 sts ,i4 argArray ,[#]@* proc dll_hdl = %dll_open('syncli_api.dll') if(dll_hdl > 0) begin argArray = new Object[4] argArray[1] = (object)producer argArray[2] = (object)application argArray[3] = (object)^addr(users) argArray[4] = (object)^addr(sys_err) sts = %dll_netcall(dll_hdl,, 'win_lm_stat', argArray) sts = %dll_close(dll_hdl) end endmain
The example below shows how to use the DllImport attribute to call a DLL in .NET. This is the preferred method.
import System; import System.Runtime.InteropServices; namespace test class Example ; Use DllImport to import the SYNCLI_API win_lm_stat function. {DllImport("syncli_api.dll", CharSet = CharSet.Ansi)} public static method win_lm_stat, int in Producer, string in Application, string out byref user, int out byref sys_err, int proc endmethod endclass main record producer ,a6 ,'999' application ,a6 ,'RUN9' users ,i4 ,0 sys_err ,i4 ,0 proc test.example.win_lm_stat(producer,application, users, sys_err) endmain endnamespace