Get structure from dll

Hi,

I try to get info from a dll file.
According to .h file:

/* BASS_VST_GetParamCount() returns the number of editable parameters for
 * the VST plugin.  If the plugin has no editable parameters, 0 is returned.
 */
BASS_VSTSCOPE int BASS_VSTDEF(BASS_VST_GetParamCount)
    (DWORD vstHandle);

I can get that by (I got vstHandle earlier):

Declare Function BASS_VST_GetParamCount Lib "bass_vst.dll" (vstHandle As Integer) as Integer
System.DebugLog ("BASS_VST_GetParamCount: " + BASS_VST_GetParamCount(vstHandle).tostring) //it's 5

Now I want the sructure, according to .h file:

/* Get some common information about an editable parameter to a
 * BASS_VST_PARAMINFO structure.
 *
 * paramIndex must be smaller than BASS_VST_GetParamCount().
 */
typedef struct
{
    char    name[16];               /* examples: Time, Gain, RoomType */
    char    unit[16];               /* examples: sec, dB, type */
    char    display[16];            /* the current value in a readable format, examples: 0.5, -3, PLATE */
    float   defaultValue;           /* the default value - this is the value used by the VST plugin just after creation */
} BASS_VST_PARAM_INFO;

BASS_VSTSCOPE BOOL BASS_VSTDEF(BASS_VST_GetParamInfo)
    (DWORD vstHandle, int paramIndex, BASS_VST_PARAM_INFO* ret);

I made a ‘param info’ struceture:

Then:

Declare Function BASS_VST_GetParamInfo Lib "bass_vst.dll" (vstHandle As Integer, paramIndex As Integer, BASS_VST_PARAM_INFO As param_info) As param_info 
Dim x as param_info
x = BASS_VST_GetParamInfo(vstHandle, 0, x)
System.DebugLog ("param_info name: " + x.name)

No error but I not get any data. What is wrong?

Also, I saw another method somewhere declare the function as ptr but I can’t follow that.
As always I’m looking for the simplest solution :slight_smile:

I believe BASS_VST_PARAM_INFO must be passed as a pointer, i.e. byRef.

x = BASS_VST_GetParamInfo(vstHandle, 0, byRef x)

Along with @Julia_Truchsess helpful information, it appears that the structure may be:

Structure

A string in a C++ dll is usually a CString or a WString. A float is also a Single data type.

2 Likes

Actually I think it’d be

BASS_VST_GetParamInfo(vstHandle, 0, byRef x)

since the info is returned via x

Oh wait, it returns a boolean.

Dim result As Boolean = BASS_VST_GetParamInfo(vstHandle, 0, byRef x)

byRef x

gives an error message,

String/CString/WString

not makes any difference

Is it allowed to upload the project? Maybe in context you see the problem instantly.

Sorry, mixing the declare with the call. Declare it:

Declare Function BASS_VST_GetParamInfo Lib "bass_vst.dll" (vstHandle As Integer, paramIndex As Integer, byRef BASS_VST_PARAM_INFO As param_info) As Boolean

Call it:

Dim result As Boolean = BASS_VST_GetParamInfo(vstHandle, 0, x)

1 Like

Great, thank you. It’s working now:

Declare Function BASS_VST_GetParamInfo Lib "bass_vst.dll" (vstHandle As Integer, paramIndex As Integer, byRef BASS_VST_PARAM_INFO As param_info) As Boolean 
dim x as param_info
Dim result As Boolean
result = BASS_VST_GetParamInfo(vstHandle, 0, x) //or just :Call BASS_VST_GetParamInfo(vstHandle, 0, x)
System.DebugLog ("param_info name: " + x.name)
System.DebugLog ("param_info unit: " + x.unit)
System.DebugLog ("param_info display: " + x.display)
System.DebugLog ("param_info defaultValue: " + x.defaultValue.ToString)

I’ll made some more experiments tomorrow, maybe I’ll have further questions if you don’t mind.

Thanks again

1 Like

Hello @Thomas_Kis,

If Julia solved the question, feel free to mark it as the answer. This will help other programmers with the helpful solution.

Thank you. :slight_smile:

1 Like

I did it earlier this day, it shows me as solved now…
Anyway, thank you both for your help.

2 Likes