I'm having some problems calling a C function from a DLL, and was hoping someone could help me out. The function is returning -101 which translates as a "bad parameter". The values I am passing have been returned from another, successful function call, so my current assumption is that I've built the structure incorrectly. Any help is appreciated.
The function definition is:
int sm_switch_channel_input(struct sm_switch_channel_parms *switchp)
Parameters
*switchp (a structure of the following type):
typedef struct sm_switch_channel_parms {
tSMChannelId channel; /* in */
tSM_INT st; /* in */
tSM_INT ts; /* in */
enum kSMTimeslotType type; /* in */
} SM_SWITCH_CHANNEL_PARMS;
typedef struct tSMChannelId_struct *tSMChannelId;
typedef int tSM_INT;
enum kSMTimeslotType {
kSMTimeslotTypeALaw,
kSMTimeslotTypeMuLaw,
kSMTimeslotTypeData,
};
And here is how I've defined & called it...
Enum kSMTimeslotType
kSMTimeslotTypeALaw = 0
kSMTimeslotTypeMuLaw = 1
kSMTimeslotTypeData = 2
End Enum
Public Structure sm_switch_channel_input_params
<MarshalAsAttribute(UnmanagedType.SysInt)> _
Public channel As IntPtr
<MarshalAsAttribute(UnmanagedType.I4)> _
Public stream As Integer
<MarshalAsAttribute(UnmanagedType.I4)> _
Public timeslot As Integer
<MarshalAsAttribute(UnmanagedType.U4)> _
Public tsType As kSMTimeslotType
End Structure
<DllImport("TiNG.dll")> _
Private Shared Function sm_switch_channel_input_iPsCtiie1_3__(ByRef x As sm_switch_channel_input_params) As Integer
End Function
Dim sscip As sm_switch_channel_input_params
Dim err as Integer
sscip.channel = chanA
sscip.stream = streamA
sscip.timeslot = timeSlotA
sscip.tsType = kSMTimeslotType.kSMTimeslotTypeMuLaw
err = sm_switch_channel_input_iPsCtiie1_3__(sscip)