Link to home
Create AccountLog in
Avatar of LEONEL ROCHA
LEONEL ROCHAFlag for Uruguay

asked on

LOAD AND USE AN EXTERNAL DLL IN C++

I've created a exported DLL in C++ to be called from a VB6 program and it is working fine:

int __stdcall fnTestEncode(PBYTE msTrack,LPSTR rcText, int cSize)
{
      return 20;
}

Now inside this function I must call some another functions that are provided by another supplier. In the supplier help manual says the following:

Installation instructions for Visual C++  6.0/ 5.0 ( MFC projects)
Create  DevSolutionsCrypt instance

1) Open the ClassWizard.
2) Click the "Add Class" button and select the "From a type library" option.
3) Find and select the "DevSolutionsCrypt.DLL" file. Even if your Visual C++ does not display files ending by "DLL", you can select "All files (*.*)" as the type of files, and then select the "DevSolutionsCrypt.DLL" file.
4) Select the "IDevSolutionsCrypt" and Visual Studio will generate two files: ""DevSolutionsCrypt.CPP" and ""DevSolutionsCrypt.H"
5) At the place you want to create your instance of "DevSolutionsCrypt include the ""DevSolutionsCrypt.H" file and create a variable of type "I"DevSolutionsCrypt" and call the "CreateDispatch" method on this variable to actually create the instance behind the wrapper object.
6) Finally, when you are finished with your instance, make sure to call the "ReleaseDispatch" method on it.

The fact is that my DLL is a WIN32 Proyect, not a MFC proyect and I can't to this.

How can I load and use the functions included in that Library in may project?

Thks in advance
Avatar of AndyAinscow
AndyAinscow
Flag of Switzerland image

>>and I can't to this.

Why not?  (Have you actually tried it)
Avatar of LEONEL ROCHA

ASKER

When i try I receive this message "MFC Classes can only be added to MFC Projects"
OK.
Is there any reason why you can't use an MFC project?

Assuming no:
Simplest for you is to create a new MFC dll project and export your current function from that.
Remember that I must export (stdcall & .DEF) the DLL to be used by VB6.0
Does MFC projects allow to do this?
I'd found the EXPORT option only in W32 projects
Yes, no problems.
ok, wait for me until next week because i'm travelling now and I'll do this next week. Sorry for the delay.
ASKER CERTIFIED SOLUTION
Avatar of AndyAinscow
AndyAinscow
Flag of Switzerland image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
I'm back, sorry for the delay. In the next hours I'll test this solution.
Solved thanks