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?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

AllenC_JrCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.