473,326 Members | 2,588 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,326 software developers and data experts.

VB.NET calling VC++.NET dll function to extract the data from a pointer.

2
Hi,

I have built a VC++.NET dll function in which you pass an array of double data and 2 additional input arguments and it returns a pointer of the data address and 2 additional scallar values.

#define CRCDLLEXPORT __declspec(dllexport) long __stdcall
/**** Methods ****/
CRCDLLEXPORT m_CrcCheck (double *pInput, // Input short nInputLength, // Input value short nCrcLength, // Input value [out] double *pOutput, // Output short *pOutputLength, // Output
short *pCrcRes); // Output


I built a VB.NET project to call the above function and extract the (pOutput) data by declaring ByRef
pOutput as it follows and setting Dim pOut() As Double

The way I am calling the function is:
nError = m_CrcCheck(pIn(0), x1, ...., pOut(0), ....)

When I am stepping into the dll function (in debug mode) I can see that *pOutput contents are updated but when I am stepping into the VB.NET code again the contents are 0.
Note that I do not delete the memory in the C++ function.

I have used the same approach in VB6 and as far I remember it worked fine.
Any suggestions/comments are welcome. Thanks.

The VB code is (in the VB class):

Public Declare Function m_CrcCheck Lib "CRC_DLL.dll" _
(ByRef pInput As Double, _
ByVal nInputLength As Short, _
ByVal nCrcLength As Short, _
ByRef pOutput As Double, _
ByRef pOutputLength As Short, _
ByRef pCrcRes As Short) As Integer

Public Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim pOut() As Double
Dim nInLen As Short
Dim i As Short
Dim nError As Integer
Dim nCrcLen As Short
Dim pOutLen As Short
Dim pCrcRes As Short

Dim pIn() As Double = {1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 1, 0, 1, 1}
nInLen = pIn.Length
nCrcLen = 8

ReDim pOut(nInLen - 1)

nError = m_CrcCheck(pIn(0), nInLen, nCrcLen, pOut(0), pOutLen, pCrcRes)

End Sub
Nov 29 '06 #1
0 1193

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Alex Lyman | last post by:
Does anyone have any code handy (or know what a good direction for me to head in), to call functions, if you have an address of the function, its declspec (for my app, it's limited to _stdcall and...
12
by: johny smith | last post by:
I am trying to figure out a way to print the address of what called a certain function once inside the function. I am assuming that this information is on the stack somewhere. But can someone...
5
by: Francesco Bochicchio | last post by:
Hi all, anybody knows if there is a (standard, portable) way to dinamically build a list of parameters to call a C function? Something like va_start & co, but to be used on the calling side? ...
2
by: darkhonor | last post by:
I'm very new to Windows development, all of my background is in Linux, so please bear with me. I am working on a class project and just for fun I'm building a frontend using VC++ 2003. The...
18
by: John Friedland | last post by:
My problem: I need to call (from C code) an arbitrary C library function, but I don't know until runtime what the function name is, how many parameters are required, and what the parameters are. I...
0
by: D Kon | last post by:
Hi, I have built a VC++.NET dll function in which you pass an array of double data and 2 additional input arguments and it returns a pointer of the data address and 2 additional scallar values. ...
11
by: briankirkpatrick | last post by:
Forgive me if my post seems a little amateurish... I'm requesting assistance from some of you smart folks out there to get the managed calls write that meet the specification in the esa.h for...
3
by: Klaus | last post by:
Hi, I have an existing VC 6 MFC application which communicates asynchronly with a VC 2005 managed code dll. I use an unmanaged base class with virtual functions to access methods in the MFC...
0
by: krishnasamy | last post by:
Hello, I am writing a DLL for Capturing the Image from Camera Device using Camera SDK DLL. All the calls made to functions in Camera SDK DLL are working properly as I am able to get a return...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.