VB Calling Convention?!

This is a discussion on VB Calling Convention?! within the Windows Programming forums, part of the Platform Specific Boards category; Hey, im trying to u'ze DLL'z in VB (Just an expierement), I wrote a simple "Hello World" DLL in MSVC++, ...

  1. #1
    Registered User minime6696's Avatar
    Join Date
    Aug 2001
    Posts
    267

    Question VB Calling Convention?!

    Hey, im trying to u'ze DLL'z in VB (Just an expierement), I wrote a simple "Hello World" DLL in MSVC++, and tried to call a function from it in VB.

    I was hopefull! The Message-Box Popped up. I press'd 'OK', then I got a calling-Convention Runtime error... I've tried like everything, I can't seem to tell VB to u'ze the "cdecl" calling convention, and I don't know wut to tell MSVC++ to compile it with to make VB Happy!

    Any idea'z???

    Thank'z a LOT for Help! ~SPH

    P.S. Here i'z my code!

    Here i'z the VB Import Code:

    Code:
    Private Declare Function dllMSG Lib "dll.dll" ()
    
    
    Private Sub Command1_Click()
        dllMSG
    
    End Sub
    Here i'z the C/C++/ASM Exported Code:

    Code:
    #include <windows.h>
    
    #ifdef __cplusplus
    extern "C"{
    #endif//__cplusplus
    
    void __declspec(dllexport) __cdecl dllMSG()
    {
    	MessageBox(NULL,"VB and C/C++/ASM MIXED!","WOOHOO!",MB_OK);
    	return;
    }
    
    #ifdef __cplusplus
    }
    #endif//__cplusplus

  2. #2
    Davros
    Guest
    Think you need to export your functions using __stdcall.

  3. #3
    Registered User minime6696's Avatar
    Join Date
    Aug 2001
    Posts
    267

    Nope...

    Nope! Still not working correctly .

    Anyone know how 2 do this??? Thank'z 4 any help! SPH

  4. #4
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Location
    Hannover, Germany
    Posts
    3,139
    If I remember correctly, you should use the WINAPI calling convention.
    hth
    -nv

    She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

    When in doubt, read the FAQ.
    Then ask a smart question.

  5. #5
    Registered User minime6696's Avatar
    Join Date
    Aug 2001
    Posts
    267

    Exclamation ???

    I'z the WINAPI Calling convention != '__stdcall'???

    Thank'z, SPH

  6. #6
    Davros
    Guest
    In that case, I think it may have something to do with name decoration.

    Check your exported function names in the DLL file using QuickView and see whether or not they have an underscore infront.

    Are you using a Borland Compiler? If so, Borland & Microsoft don't agree on the naming conventions of __stdcall and __cdecl, but there are ways to resolve this.

  7. #7
    Registered User minime6696's Avatar
    Join Date
    Aug 2001
    Posts
    267

    Smile That'z kinda wut im asking :)

    A lot of my Q i'z how 2 specify a convention in VB??? :-p!

    Thank'z a lot 4 help! , SPH

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. calling convention stdcalll and cdecl call
    By George2 in forum Windows Programming
    Replies: 1
    Last Post: 07-17-2008, 03:26 AM
  2. C++ compilation and calling from VB
    By Omar in forum C++ Programming
    Replies: 1
    Last Post: 02-13-2003, 05:36 PM
  3. calling exe from in a Dll? Help the poor VB guy!
    By nmessick in forum C++ Programming
    Replies: 5
    Last Post: 09-16-2002, 02:01 PM
  4. Calling C++ DLL from Excel VB...!
    By Tony in forum Windows Programming
    Replies: 0
    Last Post: 06-26-2002, 08:07 AM
  5. Thread calling convention
    By Sebastiani in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 05-28-2002, 07:50 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21