In VO functions from DLLs can be used with the _dll function
statement.
This works als in X#, but the ptr
datatype is not available in the Core dialect, you need something else, often the intptr
datatype, but this depends on the function declaration.
There are two possibilities in X#. The first is the VO compatible syntax:
_dll function ShowWindow(hWnd as IntPTR, nCmdShow as int) as logic pascal:user32.ShowWindow ANSI
and the other the C# compatible syntax:
[DllImport("user32.dll")] function ShowWindow(hWnd as IntPTR, nCmdShow as int) as logic pascal
For the C# syntax you need to include also
using System.Runtime.InteropServices
Of course you can also declare these functions as methods of a class:
using System.Runtime.InteropServices using System.Text class IniFile [DllImport("kernel32.dll",CharSet:=CharSet.Ansi,EntryPoint:="GetPrivateProfileString")]; static method GetString(lpAppName as string, lpKeyName as string, lpDefault as string, lpBuffer as StringBuilder, nSize as dword, lpFileName as string) as dword pascal [DllImport("kernel32.dll",CharSet:=CharSet.Ansi,EntryPoint:="GetPrivateProfileString")]; static method GetString(lpAppName as string, lpKeyName as string, lpDefault as string, lpBuffer as byte[], nSize as dword, lpFileName as string) as dword pascal [DllImport("kernel32.dll",CharSet:=CharSet.Ansi,EntryPoint:="WritePrivateProfileString")]; static method WriteString(lpAppName as string, lpKeyname as string,lpString as string, lpFileName as string) as logic pascal [DllImport("kernel32.dll",CharSet:=CharSet.Auto,EntryPoint:="GetPrivateProfileInt")]; static method GetInt(lpAppName as string, lpKeyname as string,nDefault as int , lpFileName as string) as int pascal [DllImport("kernel32.dll",CharSet:=CharSet.Ansi,EntryPoint:="GetPrivateProfileSection")]; static method GetSection(lpAppName as string, lpszReturnBuffer as byte[], nSize as int, lpFileName as string) as logic pascal end class
Please note that in the _dll statement the calling convention must be specified (in VO this is not necessary). Please see here: _dll function changes