Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. error bad dll calling convention

error bad dll calling convention

Scheduled Pinned Locked Moved Visual Basic
helpc++question
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • U Offline
    U Offline
    User 572417
    wrote on last edited by
    #1

    I'm getting the error bad dll calling convention when I call my dll written in vc++ from my vb app. The problem is because of the type / structure I'm passing my dll. In vb, I've defined my call to the dll and created a type in vb that looks like this: Declare Function test Lib "C:\TEMP\EngineTest\PSAEngine.dll" Alias "_test@10004" _ (ByVal j As Integer, ByRef collateral As collateralvar) Type assetvar cutoff_prin_bal(400) As Double orig_gross_rate(400) As Double orig_amort_term(400) As Double End Type Type collateralvar subissue(100) As Integer asset As assetvar End Type In my VC++ dll, I've defined my function and structure as: extern "C" { __declspec( dllexport ) void test(int j, collateralvar collateral); } struct assetvar { double cutoff_prin_bal[400]; double orig_gross_rate[400]; double orig_amort_term[400]; }; struct collateralvar { int subissue[100]; struct assetvar asset; }; Here is my call to the dll function: Static collateral As collateralvar . . . test 0, collateral When I call the function test in my vb program it returns the error Bad DLL calling convention. Any ideas?

    H 1 Reply Last reply
    0
    • U User 572417

      I'm getting the error bad dll calling convention when I call my dll written in vc++ from my vb app. The problem is because of the type / structure I'm passing my dll. In vb, I've defined my call to the dll and created a type in vb that looks like this: Declare Function test Lib "C:\TEMP\EngineTest\PSAEngine.dll" Alias "_test@10004" _ (ByVal j As Integer, ByRef collateral As collateralvar) Type assetvar cutoff_prin_bal(400) As Double orig_gross_rate(400) As Double orig_amort_term(400) As Double End Type Type collateralvar subissue(100) As Integer asset As assetvar End Type In my VC++ dll, I've defined my function and structure as: extern "C" { __declspec( dllexport ) void test(int j, collateralvar collateral); } struct assetvar { double cutoff_prin_bal[400]; double orig_gross_rate[400]; double orig_amort_term[400]; }; struct collateralvar { int subissue[100]; struct assetvar asset; }; Here is my call to the dll function: Static collateral As collateralvar . . . test 0, collateral When I call the function test in my vb program it returns the error Bad DLL calling convention. Any ideas?

      H Offline
      H Offline
      Hesham Amin
      wrote on last edited by
      #2

      use __stdcall in the function you declare in c++ to solve the calling convention problem

      U 1 Reply Last reply
      0
      • H Hesham Amin

        use __stdcall in the function you declare in c++ to solve the calling convention problem

        U Offline
        U Offline
        User 572417
        wrote on last edited by
        #3

        void __stdcall test(int j, collateralvar collateral); This doesn't work because your back to not being able to find DLL entry point. It must be declared as __declspec( dllexport ) void test(int j, collateralvar collateral);

        U 1 Reply Last reply
        0
        • U User 572417

          void __stdcall test(int j, collateralvar collateral); This doesn't work because your back to not being able to find DLL entry point. It must be declared as __declspec( dllexport ) void test(int j, collateralvar collateral);

          U Offline
          U Offline
          User 572417
          wrote on last edited by
          #4

          OK. I've gotten into the vc dll. I added a struct command and made it a pointer. vc dll __declspec( dllexport ) double test(int j, struct collateralvar *collateral) vb declare Public Declare Function test Lib "PSAEngine.dll" Alias "_test@8" _ (ByVal j As Integer, ByRef collateral As collateralvar) As Double Now my problem is changing the values inside the dll's collateralvar struct and having vb see them. I'm passing the structure by reference so it should work but its not. Here is what I am doing inside the dll function: __declspec( dllexport ) double test(int j, struct collateralvar *collateral) { collateral->asset.cutoff_prin_bal[j]=14; return(1); } from VB I'm calling the dll this way: dim x as double collateral.asset.cutoff_prin_bal(0) = 423149.74 x = test(0, collateral) I still get 423149.74 instead of 14.0

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups