Using a VB Active X DLL's functions in C++ 
Author Message
 Using a VB Active X DLL's functions in C++

Hi,

I've created an ActiveX DLL in VB and would like to load it into a VC++
project. I've never done this before, so I am mightily confused.

If I had a class called, TestClass, say, with one function:

Option Explicit

Public Sub PutMessageBox()
    MsgBox "Hello World!"
End Sub

What would the code look like to load the DLL (LoadLibrary?) in VC++ and run
the PutMessageBox method?

Thanks in advance,
Alain



Mon, 11 Jul 2005 00:25:50 GMT  
 Using a VB Active X DLL's functions in C++

Quote:

> I've created an ActiveX DLL in VB and would like to load it into a VC++
> project. I've never done this before, so I am mightily confused.

> If I had a class called, TestClass, say, with one function:

> Option Explicit

> Public Sub PutMessageBox()
>     MsgBox "Hello World!"
> End Sub

> What would the code look like to load the DLL (LoadLibrary?) in VC++ and run
> the PutMessageBox method?

In a header (typically, stdafx.h)
    // I used no_namespace to simplify my example code, but you may
    // wish to omit this directive and add namespace qualifiers to
    // the identifiers from the library.
    #import "yourvbdll.dll" no_namespace

(Note that if you use something like Collection, you may also need to
#import the VB runtime.)

In your code,
    // Rough VB equivalent code in comments

    // Dim pTest As TestClass
    // Set pTest = New TestClass
    _TestClassPtr pTest(__uuidof(TestClass));

    // pTest.PutMessageBox
    pTest->PutMessageBox();

--
Craig Powers
MVP - Visual C++



Mon, 11 Jul 2005 01:32:44 GMT  
 Using a VB Active X DLL's functions in C++

Thanks for that answer. It worked as you mentioned.

Sorry about the multi-post.

Regards,
Alain


Quote:

> > I've created an ActiveX DLL in VB and would like to load it into a VC++
> > project. I've never done this before, so I am mightily confused.

> > If I had a class called, TestClass, say, with one function:

> > Option Explicit

> > Public Sub PutMessageBox()
> >     MsgBox "Hello World!"
> > End Sub

> > What would the code look like to load the DLL (LoadLibrary?) in VC++ and
run
> > the PutMessageBox method?

> In a header (typically, stdafx.h)
>     // I used no_namespace to simplify my example code, but you may
>     // wish to omit this directive and add namespace qualifiers to
>     // the identifiers from the library.
>     #import "yourvbdll.dll" no_namespace

> (Note that if you use something like Collection, you may also need to
> #import the VB runtime.)

> In your code,
>     // Rough VB equivalent code in comments

>     // Dim pTest As TestClass
>     // Set pTest = New TestClass
>     _TestClassPtr pTest(__uuidof(TestClass));

>     // pTest.PutMessageBox
>     pTest->PutMessageBox();

> --
> Craig Powers
> MVP - Visual C++



Tue, 12 Jul 2005 00:15:32 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. VB Functions to C++ DLL's

2. how to use a VB active dll which include Form at a c++ program

3. Calling an VB Active X DLL from a C++ executable

4. how to use a VB active dll which include Form at a c++ program

5. Prototyping VC++ DLL functions to accept VB's AddressOf function pointer

6. Using VB-DLL functions (VGAP4-DLL) and the datatype BSTR

7. VB programmer needs help with C++ API's and DLL's

8. interfacing C/C++ DLL's with V.B.

9. Borland C C++ DLL's for VB problems

10. C C++ DLL's for VB help

11. Writing C++ DLL's for use in VB

12. HLP : VC's DLL problems when using VB 6.0

 

 
Powered by phpBB® Forum Software