?
Solved

Calling C++ dlls in VB

Posted on 1999-12-02
9
Medium Priority
?
257 Views
Last Modified: 2010-04-01
Are there any specific points to take note of when calling C++ dll functions in VB ?

regards

ManX
0
Comment
Question by:manx
9 Comments
 
LVL 4

Expert Comment

by:inpras
ID: 2249282
Some points here
1.when U R passing a string C++ dll expect always null characters in the end so send a string with null characters appended usualy vb doesnot have a null terminated string.
2. Be aware of what the dll function's parameter expects UR ByRef and ByVal are to taken care
Regards
0
 
LVL 2

Expert Comment

by:basant
ID: 2250729
Is your C++ Dll is an COM DLL which supports compatible Data types.
0
 
LVL 8

Expert Comment

by:mrmick
ID: 2251216
manx, if you ask a specific question, perhaps you'll get a useful answer...

What is it you wish to know?
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
LVL 2

Accepted Solution

by:
mflam earned 150 total points
ID: 2251424
From: MSDN:
http://msdn.microsoft.com/library/devprods/vs6/visualc/vccore/_core_calling_dll_functions_from_visual_basic_applications.htm

This is all about decoration... (which you overcome anyways if your inside VS6)
The following is from that MSDN page:

Note   A very good discussion (with example code) of calling a C DLL from Visual Basic can be found in the file VB4DLL.TXT in the VB directory.

Hope this helps.

Moshe
0
 

Author Comment

by:manx
ID: 2258023
The VB4DLL.txt file was very helpful.

A more specific question of sorts.
When I declare the C++ dll and link it to the VB module as follows :

In the C++ dll
__declspec(dllexport) void      StartHTML();

In the VB module
Private Declare Function StartHTML Lib "CGI1" ()

I get a "file not found CGI1" message from the VB compiler.

The file is in the project directory.
Are there any include statements, compiler options etc to include ?

Thanks for all the help so far

Regards

ManX
0
 

Expert Comment

by:yodan
ID: 2273813
I saw a comment about that: it's related with name decoration.
On C you only need (almost) the C function.
In C++ the compiler adds more (+arg_type, ...) to the name so you may not be able to say only "StartHtml" from CGI1.DLL.

Check documentation or ask to mflam.
0
 
LVL 8

Expert Comment

by:mrmick
ID: 2274484
I didn't realize you were still having problems...

I can prepare and send you an example if you'd like...

My email address is mick@lgman.com
0
 

Expert Comment

by:jpawar
ID: 2290345
Hi,
   One more point I think of is the function in dll which u wish to call from VB must have stdcall calling convention.

All the best

Regards
Jay
0
 

Author Comment

by:manx
ID: 2293930
Thanks A lot for all the advice.

Finally managed to get the problem solved.

Regards

ManX
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

599 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question