Home > Archive > Clarion > May 2006 > Calling clarion DLL function from C++ prototype
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Calling clarion DLL function from C++ prototype
|
|
| guxu@hotmail.com 2006-05-12, 6:55 pm |
| I have a clarion DLL function that needs be called from C++. The
prototype of the clarion DLL is:
(ULONG,*ULONG),PASCAL,NAME('ABC')
The first param is what I am passing to Clarion from C++ and 2nd one is
supposed to return the value from Clarion to C++.
I am trying to use LoadLibrary and GetProcAddress and then call this
clarion function, but have kept getting memory problem. I am thinking
that my prototype in C++ side is not right.
typedef void(WINAPI * MyProc)(LPCSTR, LPDWORD);
LPSTR a = "aaaa";
char b[100];
DWORD *dw;
dw = (DWORD *)&b;
MyProc(a, dw);
What's wrong?
| |
| clackmannan 2006-05-12, 6:55 pm |
| 1 - your prototypes for the first param are right, but you're passing a
string. So you're going to need to write code on the clarion side to
manually derefernce the pointer (since CW doesn't know what pointers
are)
2 - if the function is going to return an numeric result, why not
change the value to return the number?
fred (ulong),ulong,pascal
int fred(lpstr)
3 - you don' t need the NAME attribute if you're using the PASCAL or C
attributes, since they both disable name-mangling anyway
4 - unless you have a real need, why bother with
LoadLibrary/GetProcAddress? You should be able to link the CW .obj
right into your C application
Also, see if this helps
http://www.attryde.com/clarion/cw_prototypes.htm
| |
| guxu@hotmail.com 2006-05-12, 6:55 pm |
| Thanks so much for your help.
The clarion code (the 2nd param) is returning a String. We changed the
Clarion exported interface to both ulongs. Now the code is not
crashing, but I am not getting anything back from the 2nd param.
I really did not want to do this LoadLibrary way.
I have an activeX DLL that wrapps this Clarion DLL so I can call from
the C++ DLL code. However, it creates memory problem - the program
crashes which made me to try the LoadLibrary. I took out the line of
code in the ActiveX to call the Clarion DLL, everything works fine, no
crashes, and the return data was good. However, once I put the line of
code back in, it returns good data and then crashes with memory error.
Any clue what could be causing it?
| |
| Leonid Chudakov 2006-05-12, 9:55 pm |
| Hi,
Check VB2CW app at the examples section of the www.klarisoft.com
It shows how to call Clarion dll from VB.
--
--
Leonid Chudakov
chudakov@klarisoft.com
Cool tools and Clarion examples at
http://www.klarisoft.com
<guxu@hotmail.com> wrote in message
news:1147460334.362430.77390@j33g2000cwa.googlegroups.com...
> Thanks so much for your help.
>
> The clarion code (the 2nd param) is returning a String. We changed the
> Clarion exported interface to both ulongs. Now the code is not
> crashing, but I am not getting anything back from the 2nd param.
>
> I really did not want to do this LoadLibrary way.
> I have an activeX DLL that wrapps this Clarion DLL so I can call from
> the C++ DLL code. However, it creates memory problem - the program
> crashes which made me to try the LoadLibrary. I took out the line of
> code in the ActiveX to call the Clarion DLL, everything works fine, no
> crashes, and the return data was good. However, once I put the line of
> code back in, it returns good data and then crashes with memory error.
> Any clue what could be causing it?
>
|
|
|
|
|