How to write Visual C++ DLL's and call them from Visual Basic 
Author Message
 How to write Visual C++ DLL's and call them from Visual Basic

I know in VB I need to declare the function and indicate the filename and
path to the dll then create the same function in C++ in VB. How is the C++
file structured?

A simple example of passing in one variable into a function and return the
same or modified variable will be helpful.

I've tried this but can't get it to work (from
http://www.*-*-*.com/

C++ file...
extern "C" _declspec(dllexport)
int WINAPI Check( int iVal )
{
return iVal;

Quote:
}

C++ def file...
LIBRARY vbcpp
EXPORTS

VB file...
Declare Function Check Lib"vbcpp.dll" _
(ByVal Temp As Long) As Long

Then I called the above VB function but get an entry point error.

Thanks



Sat, 04 Jan 2003 03:00:00 GMT  
 How to write Visual C++ DLL's and call them from Visual Basic
Here are two pointers:

1. Try to use the '_stdcall'-keyword, instead of the WINAPI-keyword:

    int _stdcall Check( int iVal )
    {
    return iVal;
    }


EXPORTS
Check

If you do this, your code should work. I can send you an example if it still
doesn't work.

Regards,
Pieter Philippaerts
http://kpdteam.tripod.com/



Quote:
> I know in VB I need to declare the function and indicate the filename and
> path to the dll then create the same function in C++ in VB. How is the C++
> file structured?

> A simple example of passing in one variable into a function and return the
> same or modified variable will be helpful.

> I've tried this but can't get it to work (from
> http://www.vb2themax.com/HtmlDoc.asp?Table=Articles&ID=60

> C++ file...
> extern "C" _declspec(dllexport)
> int WINAPI Check( int iVal )
> {
> return iVal;
> }

> C++ def file...
> LIBRARY vbcpp
> EXPORTS

> VB file...
> Declare Function Check Lib"vbcpp.dll" _
> (ByVal Temp As Long) As Long

> Then I called the above VB function but get an entry point error.

> Thanks



Sat, 04 Jan 2003 03:00:00 GMT  
 How to write Visual C++ DLL's and call them from Visual Basic

Here's another pointer: if you simply *must* ask the same question in
multiple groups cross-post. Do not post separate copies of the same question
since this prevents responses in group from showing up in the others.

--
Attitudes are contagious. Is yours worth catching?
http://www.acadx.com



Sat, 04 Jan 2003 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Visual Basic 4.0 usage of DLLs written in Visual C++ 4.0

2. Visual Basic 4.0 usage of DLLs written in Visual C++ 4.0

3. How do you call a Visual C++ (DLL) function from Visual Basic

4. Calling Visual C++ 5.0 DLL Functions From Visual Basic 5.0

5. adapting Visual C++ dll for Visual Basic

6. Calling a Visual Basic DLL from C++

7. More on calling Vis C++ DLLs from Visual Basic

8. Calling a C++ Dll in Visual Basic.

9. Solution: Calling C++ dll from Visual Basic

10. Calling C++ DLLs from Visual Basic

11. visual basic 4.0 call to borland c++ 5.0 dll

12. Visual C++ DLL in Visual Basic

 

 
Powered by phpBB® Forum Software