How To: C++ DLL function returns Structure Array to VB .NET



I have a DLL that I've compiled in Visual C++ which I'm referencing in
VB .NET

The function in the DLL returns a simple structure array. I need to be
able to capture this structure array in VB .NET.

C++ code:
struct NotesInfo
{
int Note;
int StartTime;
int EndTime;
};

NotesInfo mytest(char *fHMM, char *fWaveUserQuery)
{
NotesInfo *Score;
Score = new NotesInfo[2];

Score[0].StartTime = 0;
Score[0].EndTime = 1;
Score[0].Note = 60;

Score[1].StartTime = 2;
Score[1].EndTime = 3;
Score[1].Note = 70;

return *Score;
}

above code compiles into DLL.


In VB.NET, I have coded the same structure:
Structure ScoreData
Dim Note AS Integer
Dim StartTime AS Integer
Dim EndTime AS Integer
End Structure

This is how I reference the DLL in VB .NET:
Private Declare Function mytest Lib "C:\MyLib.dll" (ByVal FileTrainData
As String, ByVal FileWaveUsrQuery AS String) AS IntPtr

I'm not sure if I need to declare mytest function as IntPtr or as
ScoreData? Either way, I need to be able to capture the structure array
output from the DLL and assign it to the structure in VB .NET

Any suggestions are greatly appreciated!
Vlad.

.



Relevant Pages

  • How To: C++ DLL function returns Structure Array to VB .NET
    ... I have a DLL that I've compiled in Visual C++ which I'm referencing in ... The function in the DLL returns a simple structure array. ... above code compiles into DLL. ...
    (microsoft.public.dotnet.languages.vb)
  • A simple question
    ... I have received from a 3rd party a DLL that contains a COM object. ... little re-jiggin this all compiles fine. ... referencing the QueryInterface function of the COM object. ...
    (microsoft.public.vc.atl)