-
Callin C dll
Hi,
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))
ReportError(retStr, 0);
else
...
I have no clue, after several tries, how to address this function. Any ideas?
Greetings,
Steven
-
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
Code:
App.Path & "\folder\file"
-
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.