Jump to content
  • Advertisement
Sign in to follow this  
GregLoutsenko

using classes from a dll writen in c++ in vb6 apps

This topic is 5049 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

the title of the thread is a bit mis-leading. what i want to know is actually a bit more. firstly if i had a dll ONLY containing this (and after compelation i had a dll.dll, dll.lib and dll.exp but no .def): extern "C" __declspec(dllexport) int Add(int a, int b) { return a+b; } how would i go about passing the relevent paramters to the function after i loaded in vb6, all i could find is this: Dim Lib As Long Dim Func As Long Lib = LoadLibrary("My_DLL.dll")'from kernel32 Func = GetProcAddress(Lib, "Add")'from kernel32 CallWindowProc Func, vbNull, vbNull, vbNull, vbNull'from user32 which didnt allow me to pass any parameters to the function Add. i did try: private declare Add lib "dll" (a as integer, b as integer) as integer, but that produced a compiler error. secondly how do i declare a a class in a dll, or can at all? if i can plz could someone point me towards a tut or preferable give me an example. and thirdly how do i use that class in vb6? thnx

Share this post


Link to post
Share on other sites
Advertisement
Your function declaration should probably look like:

Declare Function Add Lib "dll" (ByVal a As Long, ByVal b As Long) As Long

To use a native C++ class from VB isn't happy. It's sometimes possible with a lot of manual hacking, but in the end it's easier to implement it in COM and IDispatch. But until you're fairly familiar on how to get normal (C style) functions working across DLL boundaries, I wouldn't even try working with C++ objects from VB.

Share this post


Link to post
Share on other sites
well iam quite happy to using normal functions from dlls in c++and i do use them sometimes for real purposes, not just to show off, but when it comes to vb i can only call functions without paramters, never mind objects and what not. iam still reading that tut on COM. thanx for that tut btw, i was searching the net for something like that but i had no idea that i was looking for anything to do with com

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!