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



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;
}

This doesn't return an array, it returns a single NotesInfo instance.
Plus it leaks memory since you don't have any way of releasing the
array memory after the function returns.

I suggest you rewrite it to return the array via output parameters.


Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
.



Relevant Pages


Loading