Pinvoke DLL
-
I am trying to complete my project with third party dll using vb.net , i cant call the function RDA_ReadAlarmList as below , this function call return a integer value and receive the RDA_ReadAlarmList Structure and RDA_AlarmSearchParam as a parameter. Hope the bro here can help me on this , already headache for few week on this .. what --> RDS_AlarmList **outAlarmList means ? Structure array ? How should i call this in vb.net ? Function 10.8.1 It acquires an alarm list ( The asynchronousness ). int WINAPI RDA_ReadAlarmList(RDS_AlarmList **outAlarmList, RDS_AlarmSearchParam *inAlarmSearchParam); Structure 11.8.4 The alarm list search parameter typedef struct { RDE_SearchDir dir; The direction of the search RDE_SearchMode mode; The browse mode int num; The number of the searches (1-1000) bool senser[16]; The sensor true...The sensor is valid. int year; The year ( The 4 digit Christian era ) int month; The month (1-12) int day; The day (1-31) int hour; The hour (0-23) int minute; The minute (0-59) int second; The second (0-59) } RDS_AlarmSearchParam; 11.8.4 The alarm list item typedef struct { int listNumber; The list supervision number (0-9999) int alarmNumber; The alarm list number (1-10000) bool isEnable; The alarm validity / the invalidity ( true: Valid, false: Invalid ) int year; The year ( 4 digits ) int month; The month (1-12) int day; The day (1-31) int hour; The hour (0-23) int minute; The minute (0-59) int second; The second (0-59) int block; The device index int field; The field number int drive; The playback point drive number int vol; The playback point VOLUME number int camera; The camera number ( 0: The emergency, 1-: The camera number ) RDE_Alarm alarmType; The alarm type } RDS_AlarmList;
**Superbom**
-
I am trying to complete my project with third party dll using vb.net , i cant call the function RDA_ReadAlarmList as below , this function call return a integer value and receive the RDA_ReadAlarmList Structure and RDA_AlarmSearchParam as a parameter. Hope the bro here can help me on this , already headache for few week on this .. what --> RDS_AlarmList **outAlarmList means ? Structure array ? How should i call this in vb.net ? Function 10.8.1 It acquires an alarm list ( The asynchronousness ). int WINAPI RDA_ReadAlarmList(RDS_AlarmList **outAlarmList, RDS_AlarmSearchParam *inAlarmSearchParam); Structure 11.8.4 The alarm list search parameter typedef struct { RDE_SearchDir dir; The direction of the search RDE_SearchMode mode; The browse mode int num; The number of the searches (1-1000) bool senser[16]; The sensor true...The sensor is valid. int year; The year ( The 4 digit Christian era ) int month; The month (1-12) int day; The day (1-31) int hour; The hour (0-23) int minute; The minute (0-59) int second; The second (0-59) } RDS_AlarmSearchParam; 11.8.4 The alarm list item typedef struct { int listNumber; The list supervision number (0-9999) int alarmNumber; The alarm list number (1-10000) bool isEnable; The alarm validity / the invalidity ( true: Valid, false: Invalid ) int year; The year ( 4 digits ) int month; The month (1-12) int day; The day (1-31) int hour; The hour (0-23) int minute; The minute (0-59) int second; The second (0-59) int block; The device index int field; The field number int drive; The playback point drive number int vol; The playback point VOLUME number int camera; The camera number ( 0: The emergency, 1-: The camera number ) RDE_Alarm alarmType; The alarm type } RDS_AlarmList;
**Superbom**
Let me tell you this step by step. RDS_AlarmList is a structure, therefore RDS_AlarmList obj1 is one object of this structure. RDS_AlarmList *obj2 defines a pointer of this structure type. RDS_AlarmList **obj3 defines a pointer of pointer. A pointer of pointer is a pointer variable which can hold memory address of a pointer. If you want to know more about pointers of pointer, I would recommend you to search on Google, it will give you links of tutorials. -Dave.
------------------------------------ http://www.componentone.com ------------------------------------
-
I am trying to complete my project with third party dll using vb.net , i cant call the function RDA_ReadAlarmList as below , this function call return a integer value and receive the RDA_ReadAlarmList Structure and RDA_AlarmSearchParam as a parameter. Hope the bro here can help me on this , already headache for few week on this .. what --> RDS_AlarmList **outAlarmList means ? Structure array ? How should i call this in vb.net ? Function 10.8.1 It acquires an alarm list ( The asynchronousness ). int WINAPI RDA_ReadAlarmList(RDS_AlarmList **outAlarmList, RDS_AlarmSearchParam *inAlarmSearchParam); Structure 11.8.4 The alarm list search parameter typedef struct { RDE_SearchDir dir; The direction of the search RDE_SearchMode mode; The browse mode int num; The number of the searches (1-1000) bool senser[16]; The sensor true...The sensor is valid. int year; The year ( The 4 digit Christian era ) int month; The month (1-12) int day; The day (1-31) int hour; The hour (0-23) int minute; The minute (0-59) int second; The second (0-59) } RDS_AlarmSearchParam; 11.8.4 The alarm list item typedef struct { int listNumber; The list supervision number (0-9999) int alarmNumber; The alarm list number (1-10000) bool isEnable; The alarm validity / the invalidity ( true: Valid, false: Invalid ) int year; The year ( 4 digits ) int month; The month (1-12) int day; The day (1-31) int hour; The hour (0-23) int minute; The minute (0-59) int second; The second (0-59) int block; The device index int field; The field number int drive; The playback point drive number int vol; The playback point VOLUME number int camera; The camera number ( 0: The emergency, 1-: The camera number ) RDE_Alarm alarmType; The alarm type } RDS_AlarmList;
**Superbom**
In general, I would assume that the **outAlarmList indicates an array instead of just a pointer to a pointer to a single structure. The documentation of the function or some other piece of context tell you. However, you will need to declare things a little differently on the .NET side than if it was outAlarmList[]. Since the "array" seems to be an array of pointers, you will have to declare the RDS_AlarmList as a class (making sure to still mark it with the StructLayout attribute). This single pointer to the second parameter means that you want to either declare RDS_AlarmSearchParam as a Structure and pass ByRef (the normal approach) or declare it as a Class and pass ByVal So you should end up with this:
<StructLayout(LayoutKind.Sequential)> _
Public Structure RDS_AlarmSearchParam<StructLayout(LayoutKind.Sequential)> _
Public Class RDS_AlarmList<DllImport(fill in information)> _
Public Shared Function RDA_ReadAlarmList(ByVal outAlarmList() As RDS_AlarmList, _
ByRef inAlarmSearchParam as RDS_AlarmSearchParam)