Using a Visual Basic developed ActiveX dll in Borland C++ Builder 6.0

I have developed an ActiveX dll in Visual Basic and I can use this dll inside Visual Basic by just adding the dll using
Project>References then select the dll file.
That way I was able to call the dll using
 Dim a as new MyClassInVB

the code in VB has a function declaration of

public function GetInt() as integer
and this works well in VB

However, I need to use this dll inside Borland C++ Builder 6.0
So I used this method

//header file
class myclass
    typedef int (WINAPI* typeGetInt) (void);
    typeGetInt  GetInt;

//cpp file
void myclass::LoadMyDll(void)
int a = 0;

    HINSTANCE hSTM = LoadLibrary("myclassdll.dll");

    if (hSTM != NULL)
        GetInt = (typeGetInt) GetProcAddress(hSTM,"GetInt");

   a = GetInt();


However when it runs to a=GetInt();
an exception:
Project MyApp.exe raised exception class EAccessViolation with message 'Access violation at address 00000000. read of address 00000000'. Process stopped. Use Step or Run to continue.

There must be a way to use active X dlls in Borland C++ but I don't know how.

The above method works well for the dlls I've developed in Visual C++ 6.0.
Thanks in advance!
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Oh! No!


ActiveX are imported as components. LoadLibrary and GetProcAddress just won't work.

The Access violation you are getting is correct. Specially since the value of return of GetProcAddress is NULL (You should check it ouy before calling it!):

GetInt = (typeGetInt) GetProcAddress(hSTM, "GetInt");
if(GetInt != NULL)
  a = GetInt(); // this code will never execute !!!!

To use an ActiveX under BCB you need to import it into a package library by using the Projects->Import Type Library menu.
The procedure is thoughtfully documented on BCB's online help.

Once you import the ActiveX all its controls will be available for you to use inside the BCB enviroment as "native" components, and you'll use it as if you were using it on VB.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
preddibearAuthor Commented:
Hey Thanks!
Your answer came in just on time!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Editors IDEs

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.