473,386 Members | 1,706 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

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

Hello,

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.

Sep 16 '06 #1
0 1491

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

17
by: Roland Hall | last post by:
Is there a way to return multiple values from a function without using an array? Would a dictionary object work better? -- Roland Hall /* This information is distributed in the hope that it...
2
by: Chris Haynes | last post by:
Hello all, I have a structure: typedef struct UVstruct { float u, v; } uv; Inside a function (A) i declare a pointer to an instance of this structure:
0
by: kagorami | last post by:
Q: How do you return a LPSTR from unmanaged code? A: Use a StringBuilder. What about this: public struct CSTRUCT { string return_value; } How do you get a LPSTR from unmanaged code when it...
10
by: David Fort | last post by:
Hi, I'm upgrading a VB6 app to VB.net and I'm having a problem with a call to a function provided in a DLL. The function takes the address of a structure which it will fill in with values. I...
17
by: I.M. !Knuth | last post by:
Hi. I'm more-or-less a C newbie. I thought I had pointers under control until I started goofing around with this: ...
6
by: Jahangir | last post by:
Hello All, In my project I am using php calendar. I have used it locally it is working perfactly, but when I upload it on remote server it gives Fatal error: Call to a member function on a...
5
by: shanfeng | last post by:
such as a function: f(double v, int a) could this function return both a integer and array? Thank you very much. I have confused on this for a long time~
160
by: DiAvOl | last post by:
Hello everyone, Please take a look at the following code: #include <stdio.h> typedef struct person { char name; int age; } Person;
5
by: ctj951 | last post by:
I have a very specific question about a language issue that I was hoping to get an answer to. If you allocate a structure that contains an array as a local variable inside a function and return...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.