Access Boraland C++ builder dll in visual c++

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kirubanantham
    New Member
    • Nov 2006
    • 8

    Access Boraland C++ builder dll in visual c++

    Hai Friends,
    Any body knows how to Access dll (Created by Boraland C++ builder 5.0) in Visual c++ 6.0.
    i am Trying the following method
    Dll Function :- Myfunc(int *a)

    //Code
    typedef void (WINAPI*cfunc)( int *a);
    cfunc Myfunc;
    void main() {
    HINSTANCE hLib=LoadLibrar y("projdll.dll" );//DllCreateProjec t1DLLTEST
    if(hLib==NULL) {

    cout << "Unable to load library!" << endl;
    getch();
    return;
    }
    Myfunc=(cfunc)G etProcAddress(( HMODULE)hLib, "Myfunc");
    int a;
    Myfunc(&a);
    FreeLibrary((HM ODULE)hLib);
    getch();
    }
    but i am getting access violation error.
    any body can help me?

    Thank you,
    Kiruba.
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    Originally posted by kirubanantham
    Myfunc=(cfunc)G etProcAddress(( HMODULE)hLib, "Myfunc");
    You didn't check Myfunc for NULL before using it. If GetProcAddress can't find your function in the DLL, it returns NULL.

    Was the DLL built with a C++ compiler?? If so, you have top do some things to the DLL when you build it to defeat the C++ name mangling feature. If you don't, the mangled function names are the ones in the DLL. When you are requesting "Myfunc", which is not mangled, GetProcAddress will will never find it.

    Comment

    Working...