06170253.txt 17-Jun-00
CALL VO DLL FROM MFC C++
Forum: CA-Visual Objects 2
Section: VO Programming
Subj: use VO DLL under VB
To : Alberto Plottier, 70501,3327 10/25/99 12:55 PM
From : Uwe Heyer, 100060,1141 #71992
Alberto,
you are welcome
Please be aware that your function name is case sensitive
e.g. MyFunc() != myfunc() != MYFUNC()
below is a sample how to call a VO DLL from a MFC/C++
application
Here we have the problem with Name Mangeling / Decoration
I get rid of that with the help of a .DEF file and LIB.EXE
for creating a import library
The sample shows how to call the VO function with a pointer
call and call through the linker bind
Please note, this sample is defined as STRICT (C standard
call method)
1.) Mit VO eine TEST.DLL erzeugt
FUNCTION TestMe(i1 AS INT, i2 AS INT) AS INT STRICT
RETURN i1 * i2
2.) Mit Edit eine TEST.DEF geschrieben
LIBRARY TEST.DLL
EXPORTS
TestMe
3.) Eine ImportLibray TEST.LIB erzeugt
LIB /DEF:TEST.DEF
4.) DevStudio aufgestartet
extern "C" int TestMe(int, int);
BOOL CETCanonApp::InitInstance()
{
typedef int (* dlltest) (int, int);
dlltest test;
int i1 = TestMe(3, 2); // Durch Linker gebunden
// Uber Funktionspointer
HINSTANCE hTest = LoadLibrary("Test.dll");
test = (dlltest) GetProcAddress(hTest, "TestMe");
int i2 = test(3, 2);
FreeLibrary(hTest);
.....
return TRUE;
}
Ahoj
Uwe
               (
geocities.com/n_s_wong/vo)                   (
geocities.com/n_s_wong)