Set up DLL functions

The examples were tested by using Visual Studio Professional 2017. The usage with other Visual Studio versions requires maybe modifications.

Bellow you can find the description how to define the .DLL functions. All functions are described in the CDBASE.CHM file.

Hint

In the following examples the 64-Bit DLLs are used

// In this example 64bit dlls are used (Visual Studio Platform 64bit)

// sof_cdb_init
[DllImport("sof_cdb_w-2022.dll", CallingConvention=CallingConvention.Cdecl)]
public static extern int sof_cdb_init(
    string name_,
    int initType_
);

// sof_cdb_close
[DllImport("sof_cdb_w-2022.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern void sof_cdb_close(
    int index_);

// sof_cdb_status
[DllImport("sof_cdb_w-2022.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern int sof_cdb_status(
    int index_);

// sof_cdb_flush
[DllImport("sof_cdb_w-2022.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern int sof_cdb_flush(
    int index_);

// sof_cdb_free
[DllImport("sof_cdb_w-2022.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern int sof_cdb_free(
    int kwh_,
    int kwl_);

// sof_cdb_kenq_ex
[DllImport("sof_cdb_w-2022.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern void sof_cdb_kenq_ex(
    int index,
    ref int kwh_,
    ref int kwl_,
    int request_);

// sof_cdb_get
[DllImport("sof_cdb_w-2022.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern int sof_cdb_get(
    int index_,
    int kwh_,
    int kwl_,
    void* type_,
    ref int recLen_,
    int pos);

Set up the Environment [PATH]

It is also necessary to define the environment path:

int index = 0;
int status = 0;
int datalen;

string directory1 = @"C:\sofistik_installation\2022\SOFiSTiK 2022\interfaces\64bit";
string directory2 = @"C:\sofistik_installation\2022\SOFiSTiK 2022";
string cdbPath = @"S:\test\simple_span_girder.cdb";

// Get the path
string path = Environment.GetEnvironmentVariable("path");

// Set the new path environment variable + SOFiSTiK dlls path
path = directory1 + ";" + directory2 + ";" + path;

// Set the path variable (to read the data from CDB)
System.Environment.SetEnvironmentVariable("path", path);
The environment path must be defined before .DLL functions are called.
In this example environment path is set to:
C:\<sofistik_installation>\2022\SOFiSTiK 2022\interfaces\64bit
C:\<sofistik_installation>\2022\SOFiSTiK 2022

An already defined project can be found by following:

C:\<sofistik_installation>\2022\SOFiSTiK 2022\interfaces\examples\c#\connect_to_cdb