January 19th, 2011, 06:40 AM
Callin C dll
I'm trying to write a VB6 program to communicate with a C dll.
In C the function is defined as follows:
/* You may need to construct a directory path in front of df_main.dll */
theDLL = LoadLibrary("df_main.dll");
theFunc = (DLLPROC)GetProcAddress(theDLL, "mbedEntryPoint")));
/* Call DF engine */
retStr = (*theFunc)(cmd);
if (!strnicmp(retStr, "error", 5))
I have no clue, after several tries, how to address this function. Any ideas?
January 19th, 2011, 08:58 AM
Re: Callin C dll
VB6 doesn't have pointers, if that's what you want to know.
is how you refer to a folder when you know where it is
and when you don't
App.Path & "\folder\file"
January 19th, 2011, 06:47 PM
Re: Callin C dll
I'm afraid you can't call that function as-is from VB. Assuming the cmd parameter passed to the DLL function in your code sample is a usual C string (char * in C) you can pass it from VB; you'd just need to specify it as ByVal in the VB parameter list of the DLL function. But the return value from the DLL (assigned to retStr in the sample code) seems to be a char * (pointing to a C string) as well, and AFAIK it can't be passed back to VB that way.
Therefore you would likely need to either change the DLL function or write a wrapper function (inside the DLL in question or another one) that then is to be called from VB.
This thread may contain interesting background information on that topic for you: http://www.codeguru.com/forum/showthread.php?t=500031. The VB program discussed there is Excel VBA and the DLL in question is written in assembly language, but that doesn't make a difference for calling the DLL function.
Please use code tags when posting code.
I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.
This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.
Tags for this Thread
Click Here to Expand Forum to Full Width
This is a Codeguru.com survey!