Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

iNsAn1tY

Functions in a DLL...

This topic is 5571 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

I'm currently writing *.3ds and *.obj model file loaders for my level editor. However, I have a problem: I'm writing the editor in VB (for the time being; MFC coming soon) and writing the loaders (along with a few other important functions) in nice, friendly C. I've put the loaders and other code in a DLL, but I'm having trouble linking to the functions. I tried Public Declare Function to no avail (error said it couldn't find my DLL, "core.dll"), then tried to use GetProcAddress(). This didn't work either (I didn't think it would; no pointers in VB). Before all this, I tried to load the DLL in the "References..." menu, but it couldn't be loaded. The DLL is properly formatted (although it doesn't have DllMain() function), and the functions are listed as EXPORTS in a *.def file. I've tried to load it with my C engine, and it loaded fine, and I could find all the functions. I've seen people mention that they use VB for the UI, and store the C renderer in a DLL. I'd like to have the DLL in the same directory as the program executable. I know there's probably a simple solution to this, but I've lost my MSDN disc . Thanks in advance for any replies...

Coding Stuff ->  [ iNsAn1tY Games | DarkVertex | How To Do CSG | Direct3D Vs. OpenGL | Google ]
Fun Stuff    ->  [ Evil T-Shirts | Stick-Based Comedy | You're Already Here | The Best Film Reviews ]
[edited by - iNsAn1tY on June 16, 2003 4:01:57 PM]

Share this post


Link to post
Share on other sites
Advertisement
If you put the DLL in Windows\System it should be able to find it. Also, be careful with ByVal and ByRef in your declare statement, sometimes when you think it should be one way, it is actually another. For instance, Strings are actually ByVal.

Share this post


Link to post
Share on other sites
You must use the __stdcall calling convention for all your exported function you want to call from within VB.

You can do this using one of two methods.

1. Tell your compiler to use __stdcall for all functions.

In Visual C++, goto Project->Settings, click on the C/C++ tab and select "Code Generation" in the category combo box, then select __stdcall for the calling convention.

2. Comtinue to use the default __cdecl calling convention and use __stdcall for your exported library functions.

Best way to implement this is to define the calling convention and use this were necessary...

#define MYDLLAPI __stdcall


void MYDLLAPI MyExportedFunction(void)
{
}


I hope this helps ;-)

- Kevin

[edited by - moNoKnoT on June 17, 2003 2:18:17 PM]

Share this post


Link to post
Share on other sites
Thanks for the replies. I've finished most of the C functions I need for my map editor, and now all I need to do is put them in the DLL. Sailorstick, I'll put my DLL in c:\Windows\System for the time being, but I'd still like to have it in the same directory as the executable. Anyone got any idea whether this is possible? If it's not, I'll just wait until I write the C++/MFC version of my editor. moNoKnoT, thanks for the heads-up on the __stdcall stuff...



Coding Stuff ->  [ iNsAn1tY Games | DarkVertex | How To Do CSG | Direct3D Vs. OpenGL | Google ]
Fun Stuff    ->  [ Evil T-Shirts | Stick-Based Comedy | You're Already Here | The Best Film Reviews ]


[edited by - iNsAn1tY on June 25, 2003 7:27:02 AM]

Share this post


Link to post
Share on other sites
Guest Anonymous Poster

http://msdn.microsoft.com/

online msdn

Share this post


Link to post
Share on other sites

  • 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!