C++ ActiveX dll in VB 
Author Message
 C++ ActiveX dll in VB

Champions,

Hope I have the correct bulletin board and hope someone can help me.

I have to re-write a VB ActiveX dll in C++ and amoungst other things,
copy its interface.  It currently interfaces with a Visual Basic
client.  Needless to say there is no useful documentation on the
current implementation available to me and I am not a Visual Basic
programmer.

Can anyone tell me the correct way to declare a C++ ActiveX dll in
Visual Basic so that I can test my dll's API?

The current VB test client (testing the VB ActiveX dll) includes the
code:

(General) (Declaration) section

Dim MyObject as aXObj   'name of ActiveX dll

then in the 3 API sub-routines:

Private Sub Command1_Click()
Set anObject = aXObj
...
anObject.APIFunctionCall

The variable 'anObject' is never explicitly declared.

Is that declaration and use correct and can I copy it for C++?

NB
On initialisation the dll performs operations which only need to be
performed once, loading some .ini file settings.  I do not want to
have the dll re-initialised each time a call to one of the API
functions is made.

Thanks,

Mark



Sun, 04 Sep 2005 01:24:15 GMT  
 C++ ActiveX dll in VB
Inline :-


Quote:
>Champions,

>Hope I have the correct bulletin board and hope someone can help me.

>I have to re-write a VB ActiveX dll in C++ and amoungst other things,
>copy its interface.  It currently interfaces with a Visual Basic
>client.  Needless to say there is no useful documentation on the
>current implementation available to me and I am not a Visual Basic
>programmer.

The current VB AX DLL should come with a Type Library xxx.TLB
VB (and other languages) read that to find the exposed procedures and
their parameters.

You can work those out from running up a simple test App

Quote:

>Can anyone tell me the correct way to declare a C++ ActiveX dll in
>Visual Basic so that I can test my dll's API?

>The current VB test client (testing the VB ActiveX dll) includes the
>code:

>(General) (Declaration) section

We call this 'Module Level'

Quote:

>Dim MyObject as aXObj       'name of ActiveX dll

This creates a pigeon hole that you can use to hold an instance of the
Class

Quote:

>then in the 3 API sub-routines:

>Private Sub Command1_Click()
>Set anObject = aXObj

Set MyObject = New aXObj

\_ this creates a new instance in MyObject
     and may destroy the old instance in MyObject

Set anObject = aXObj
will simply make  anObject  point to whatever is in aXObj
- which in this case is illegal as aXObj is a Class not an instance of
a Class

Better do:  Set MyObject = New aXObj
just once - in some sort of initialization routine
and Set MyObject = Nothing when you want to destroy the Object

Quote:
>...
>anObject.APIFunctionCall

>The variable 'anObject' is never explicitly declared.

It should be explicitly declared.
Quote:

>Is that declaration and use correct and can I copy it for C++?

>NB
>On initialisation the dll performs operations which only need to be
>performed once, loading some .ini file settings.  I do not want to
>have the dll re-initialised each time a call to one of the API
>functions is made.

Well - VB or rather the VB programmer will control that

Out of interest, does it _have_ to be an AX DLL ?

It is much easier to write 'real' DLLs and 'front' them with a VB
Class - instances can be referred to using Handles that the 'real' DLL
can feed back to VB

IMO the only reasons for writing AX DLLs in another language than VB
is when the thing is an OCX with a visual interface, or it is going to
raise events in say a Form or a Class

HTH



Mon, 05 Sep 2005 01:20:54 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. accessing objects in a c++ DLL from a c++ activeX control placed in a VB application

2. Rewrite VB activeX dll to C++

3. VB-ActiveX-DLL access violation error when call from C++

4. VB and C++ clients declaring the same ActiveX .dll

5. VB and C++ Clients declaring the same ActiveX .dll

6. Calling VB ActiveX DLL from Visual C++ problem

7. SPEED: VB5 ActiveX DLL vs C++ ATL COM DLL

8. I need testers for serial port comm DLL and alpha paging DLL (Delphi, C/C++, VB)

9. VB DLL reading from ADO and colliding with C++ DLL reading there too (on NT)

10. DLL question -- integrating VB with C++ DLL

11. VB 5.0 calling C++ 5.0 DLL that calls winsock.dll

12. ActiveX DLL for Visual C++?

 

 
Powered by phpBB® Forum Software