VC++ dll in VB app ?

Hi,

I am trying to run a VC++ dll in a VB application.

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 "CGI" ()

The function is accessed as

StartHTML

Is this correct ?

I get a "file not found CGI" message from the VB compiler.
The file is in the project directory.

Are there any include statements, compiler options etc to include ?

Regards

ManX

manxAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
AllenC_JrConnect With a Mentor Commented:
OK, this is a suggestion, reject it if it doesn't work out...

I would suggest you Remove the File from the Project Directory and move it to the Windows\System Directory.  The reason is simple.  You can't call a file all the time from the Project's dir.  Sometimes (if not all) Visual Basic will take the current directory (like if you open a file with the common dialog).  After doing that you *might* get the error "StartHTML" not found in 'CGI.dll'.

And you are exporting it right but you need a .def file for it to be 'clean' code for Visual Basic.

(you can declare the def file like ...)

EXPORTS
    StartHTML=1@PRIVATE

If your declaration still errors by saying file not found you may have to add the .dll extention to the File in the "lib" area.

I hope this helps...

-Linguar
0
 
manxAuthor Commented:
Now it say "Can't find DLL entry point StartWML in CGI"

I don't understand what you mean by def file. Could you please clarify ?

Regards

ManX
0
 
AllenC_JrCommented:
OK a .def file is a file that C++ uses to define exact parameters when doing certain tasks to a .dll or .exe, in your case Exporting.

Create a new file in your C++ project and give it a .def extention, open the file in the c++ project and open the properties dialog and under "language" select "None".

OH, one thing you *can* remove the __declspec(dllexport), after using the .def file.  The text "__declspec(dllexport)" exports the method JUST fine, but there is one problem it exports many other symbols with it (like "1@StartHTML???" or something similar).  If you remove the "__declspec(dllexport) " and add the new .def file (create a new text file in your source folder and rename it to .def extention, and drag it into the project view) it should work fine.

The declaration in VB is exactly right.

Just in case: Make sure though that after making VB use the dll(as you probably know) include it with the setup file...

If you need more help with this go to "http://www.vb-helper.com" click on the "Advanced" section and select "Create a VC++ DLL file for use with Visual Basic (60K)".

That is about all I can tell you.

-Linguar
0
All Courses

From novice to tech pro — start learning today.