Thread: DLL __cdecl doesnt seem to work?

  1. #1
    Registered User Xei's Avatar
    Join Date
    May 2002
    Posts
    719

    DLL __cdecl doesnt seem to work?

    I am currently having problems with a DLL, the DLL will work fine in C++ however I am trying to make the DLL portable with VB so that my friends can use the DLL's made in C++ when they just need the power that VB cannot assign. Currently I am working with a Dynamic Linked Library, not Static. Im using the __declspec(dllexport) definition. I checked MSDN and they said that VB always uses __cdecl for API calling convention. However the DLL will run just fine in VB until the DLL has to return a value, then it all just crashes and the DLL doesnt get shut down etc.. I have tried adding the compile option Gd, and Gz (both seperate compiles ofcourse) and VB still gives the "Bad DLL Calling Convention" error, I am not quite sure what I am doing wrong in the DLL, here is a sample of what Im putting in the header file:
    Code:
    #ifdef __cplusplus
    #define EXPORT extern "C" __declspec (dllexport)
    #else
    #define EXPORT __declspec (dllexport)
    #endif
    
    EXPORT int TestB(char *Say);
    It's just a silly sample DLL that i've been working with to try to get it working with VB properly. "void" functions work perfectly, its when they have to return a value when it doesnt work properly.

  2. #2
    "The Oldest Member Here" Xterria's Avatar
    Join Date
    Sep 2001
    Location
    Buffalo, NY
    Posts
    1,039
    wha'd are you on drugs?

    you can't make a dll using c++ and use it with vb without linking it to MSVBVM60.dll

    thus your way will not work, as MSVBVM60.dll accepts only cdecl statements specifically made by a microsoft devleoper(as in, the people in the company)compiler which is meant to make vb libraries, or made by vb professional itself

    i tried to find a solution but i couldn't. i'm still looking

  3. #3
    I lurk
    Join Date
    Aug 2002
    Posts
    1,361
    No, you're wrong. A quick search on google came up with: http://www.vsj.co.uk/archive/hovb-9905.asp

  4. #4
    C++ Developer XSquared's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    2,718
    Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah

    You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie

  5. #5
    Unregistered
    Guest

    Thumbs up Thankyou

    Thankyou Eibro and XSquared, the websites that you provided have been useful in assisting me create the DLL's compatible and taught me a couple other useful things.

  6. #6
    "The Oldest Member Here" Xterria's Avatar
    Join Date
    Sep 2001
    Location
    Buffalo, NY
    Posts
    1,039
    aren't you going to thank me too? i'm the one who made people actually research

  7. #7
    Registered User Xei's Avatar
    Join Date
    May 2002
    Posts
    719

    Wink Okay...

    Yes.... thanks

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. problem in calling DLL
    By bhagwat_maimt in forum C++ Programming
    Replies: 2
    Last Post: 11-19-2006, 10:43 PM
  2. Error C2664 - Trying to call an external Dll
    By jamez05 in forum C++ Programming
    Replies: 3
    Last Post: 08-08-2006, 06:07 AM
  3. debug dll
    By axr0284 in forum C++ Programming
    Replies: 3
    Last Post: 03-06-2006, 04:52 PM
  4. Calling a VB DLL w/ forms from C++ DLL
    By UW_COOP in forum C++ Programming
    Replies: 8
    Last Post: 06-30-2003, 08:04 AM