Solved

VB and VC++

Posted on 1998-11-09
6
303 Views
Last Modified: 2010-04-30
hi,
I am currently trying out the following:
1) create a simple push button (command1) on form1
2) have a simple function callback in VC++ and build as dll
3) try to import the dll using Project->Reference so that when command1.click, i can call the VC++ function. however, there's an error when i try to add the dll using Project->References.

Please advise on the steps necessary to call the VC++ functions from my VB forms.

thanks,
hui
0
Comment
Question by:andreat
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
6 Comments
 
LVL 4

Accepted Solution

by:
tomook earned 20 total points
ID: 1443900
VB project references are for ActiveX objects. If you are making a standard DLL, use the Declare keyword in VB.
0
 
LVL 4

Expert Comment

by:tomook
ID: 1443901
Post your C function prototype and I can help you with the Declare syntax.
0
 

Author Comment

by:andreat
ID: 1443902
hi tomook,
I've tried playing around on my own based on the VB and VC++ online help and this is what i've done:

1) create a Win32 dll type project. at Project->Settings->Link, check Generate Mapfile

2) create a simple function
#include <iostream.h>
#include "testout.h"

void FuncCall(void)
{
      cout<<"hello"<<endl;
}

3) testout.h contains the following lines:
#define DllExport __declspec( dllexport )
void DllExport __cdecl FuncCall(void);

4) create a new VB project with a push button (command1)

5) create a new module with the following line :
Declare Sub FuncCall Lib "c:\project\vb\testout.dll" ()

6) add the following function callback
Private Sub Command1_Click()
Call FuncCall
End Sub

When I run the project, I have the following error message:
"Run-time error 453
Can't find DLL entry point FuncCall in c:\project\vb\testout.dll"

Please advise.
Thanks.
hui


0
Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

 
LVL 4

Expert Comment

by:tomook
ID: 1443903
First, VB likes things better as functions. Try redefining as
long FuncCall(void)
and
Declare Function FuncCall Lib "c:\project\vb\testout.dll" () As Long

Second, you will need to write a .DEF file. To find out what to put in it, create a link map in C++. Your will probably find your function will be "adorned" with extra characters. This can be mapped in the .DEF file.
0
 

Author Comment

by:andreat
ID: 1443904
hi
I will try out your advice.
The reason why I didn't create a .DEF file was because the help notes state that if I used __declspec(dllexport), I don't need to.
Also, do I have to check the VC++ Project->Settings->Link, Generate Mapfile option? what is it used for?

thanks,
hui
0
 
LVL 4

Expert Comment

by:tomook
ID: 1443905
I am afraid with VB you always need a .DEF file. I have never had it work correctly yet between VC++ and VB without one.

The map will tell you what you need to put in the .DEF file. It will show you the decorated name which you will expose as a simple name.
0

Featured Post

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

730 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