Calling C DLL from VB

N

Nick

I have read many postings regarding the above thread but don't seem to
have found the exact problem I am experiencing.

I am using VS.NET and have 2 projects within the 1 solution. First
project is a VB module (compiled to .EXE) and is the calling module.
The 2nd project is C and compiles to a DLL.

The DLL takes the definition of an ARC(4 Points) and converts this
geographically into a string of Points. The DLL was written in C
because of the math and speed requirements.

Here is the declare in VB:
Declare Function ConvertArctoString Lib "convarc.dll" Alias
"_ConvertArctoString@8" (ByVal sDir As Short, ByVal ParamArray
allPts() As AspMap.Point) As Integer

Here is the declare in C module:
#define CONVARC_API __declspec(dllexport)
CONVARC_API long PASCAL ConvertArctoString (long, PPOINTD);

The problem I am having is:
1. C DLL does not appear to load when I view the Modules window.
2. Can place a breakpoint in C source but when I DEBUG VB EXE the
breakpoint
in C module never reached and the IDE reports that no symbol
information could be found!
3. I get a GPF when I start assigning the coordinate x and y values in
the DLL with above declare. Cant use ByRef with ParamArray.
4. If I do NO assignment the VB variable appears to have been nulled
on return from the DLL!!

In light of this wrote simple function.
Here is the code:
CONVARC_API long PASCAL ArcStart2(PPOINTD arcPts)
{
arcPts[0].x = 999.0;
arcPts[0].y = 999.0;
return arcPts[0].x/2;
}

and the DECALRE/call from VB module:
Declare Function ArcStart2 Lib "convarc.dll" Alias "_ArcStart2@4"
(ByRef iPts As AspMap.Point) As Integer
Dim testPt As New AspMap.Point()
iNumPts = ArcStart2(testPt)

interestingly iNumPts gets returned with 499 so appears the assignment
works but the variable testPts gets set to "Nothing" on return from
DLL.

Am lost without debug and not sure how to get DLL to load. I can't
add as a reference in the VB project as I get an error saying it is
not a valid .NET assembly!
 
J

Jack Klein

I have read many postings regarding the above thread but don't seem to
have found the exact problem I am experiencing.

This is a Windows issue, not a C language issue, and you need to ask
about in one of the Microsoft support groups in the
family somewhere.

The C language does not define or support any of DLLs, .net, or VB.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++ ftp://snurse-l.org/pub/acllc-c++/faq
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top