473,378 Members | 1,333 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,378 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 1021

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...
8
by: Andreas Lagemann | last post by:
Hi, after browsing FAQ and archive for a while I decided that the following is a legal question. Consider this: Class Base { public: Base() {}
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: 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...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.