DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 7 of 7

Thread: Dll function call problem

  1. #1
    Pete Mitchell Guest

    Dll function call problem


    I keep getting the runtime error '49' "Bad DLL calling convention" error message

    when calling a function in a dll from my VB program.
    It's C syntax is:
    long Julian_Date(char *szDate)

    Here is my Declaration in the General Decs of a form:
    Private Declare Function Julian_Date Lib "d:\Chariotts\qengine.dll" (ByVal

    sDate As String) As Long

    Here is the call to the function from a button click event:
    Private Sub Command1_Click()
    Dim retval As Long
    Dim sDate As String

    sDate = "19990625"
    retval = Julian_Date(sDate)

    End Sub

    I have also tried changing the function declaration to pass the parameter
    ByRef with the same result.

    I have successfully called this function from Visual FoxPro so I figured

    that the function is exposed and available.

    What am I doing wrong ????

    Thanks in advance.


  2. #2
    Mattias Sjögren Guest

    Re: Dll function call problem

    Pete,

    >It's C syntax is:
    >long Julian_Date(char *szDate)


    If you have the sourcecode for the DLL, change that to

    long _stdcall Julian_Date(char *szDate)

    If you don't, then there's no way to directly call this function in
    VB. You either have to create your own wrapper DLL, or use some third
    party product.


    Mattias

    ____________________________________________
    Mattias Sjögren - mattiass @ hem.passagen.se
    http://hem.spray.se/mattias.sjogren/

  3. #3
    Mattias Sjögren Guest

    Re: Dll function call problem

    Pete,

    >It's C syntax is:
    >long Julian_Date(char *szDate)


    If you have the sourcecode for the DLL, change that to

    long _stdcall Julian_Date(char *szDate)

    If you don't, then there's no way to directly call this function in
    VB. You either have to create your own wrapper DLL, or use some third
    party product.


    Mattias

    ____________________________________________
    Mattias Sjögren - mattiass @ hem.passagen.se
    http://hem.spray.se/mattias.sjogren/

  4. #4
    Michael Culley Guest

    Re: Dll function call problem


    Mattiass and Pete,

    If the function type is not specified it defaults to declspec?

    If so I have some VB code that will call this. Email me if you would like
    a copy.

    Michael Culley

    mattiass.dont.want.spam@hem.passagen.se (Mattias Sjögren) wrote:
    >Pete,
    >
    >>It's C syntax is:
    >>long Julian_Date(char *szDate)

    >
    >If you have the sourcecode for the DLL, change that to
    >
    >long _stdcall Julian_Date(char *szDate)
    >
    >If you don't, then there's no way to directly call this function in
    >VB. You either have to create your own wrapper DLL, or use some third
    >party product.
    >
    >
    >Mattias
    >
    >____________________________________________
    >Mattias Sjögren - mattiass @ hem.passagen.se
    > http://hem.spray.se/mattias.sjogren/



  5. #5
    Michael Culley Guest

    Re: Dll function call problem


    Mattiass and Pete,

    If the function type is not specified it defaults to declspec?

    If so I have some VB code that will call this. Email me if you would like
    a copy.

    Michael Culley

    mattiass.dont.want.spam@hem.passagen.se (Mattias Sjögren) wrote:
    >Pete,
    >
    >>It's C syntax is:
    >>long Julian_Date(char *szDate)

    >
    >If you have the sourcecode for the DLL, change that to
    >
    >long _stdcall Julian_Date(char *szDate)
    >
    >If you don't, then there's no way to directly call this function in
    >VB. You either have to create your own wrapper DLL, or use some third
    >party product.
    >
    >
    >Mattias
    >
    >____________________________________________
    >Mattias Sjögren - mattiass @ hem.passagen.se
    > http://hem.spray.se/mattias.sjogren/



  6. #6
    ken guest Guest

    Re: Dll function call problem


    Do you have 'Julian Date' listed in the EXPORT paragraph of your .def file?
    Also you [may] need to declare szDate as an LPSTR.



    "Pete Mitchell" <pmitchel@attachegroup.com> wrote:
    >
    >I keep getting the runtime error '49' "Bad DLL calling convention" error

    message
    >
    >when calling a function in a dll from my VB program.
    >It's C syntax is:
    >long Julian_Date(char *szDate)
    >
    >Here is my Declaration in the General Decs of a form:
    >Private Declare Function Julian_Date Lib "d:\Chariotts\qengine.dll" (ByVal
    >
    >sDate As String) As Long
    >
    >Here is the call to the function from a button click event:
    >Private Sub Command1_Click()
    > Dim retval As Long
    > Dim sDate As String
    >
    > sDate = "19990625"
    > retval = Julian_Date(sDate)
    >
    >End Sub
    >
    >I have also tried changing the function declaration to pass the parameter
    >ByRef with the same result.
    >
    >I have successfully called this function from Visual FoxPro so I figured
    >
    >that the function is exposed and available.
    >
    >What am I doing wrong ????
    >
    >Thanks in advance.
    >



  7. #7
    ken guest Guest

    Re: Dll function call problem


    Do you have 'Julian Date' listed in the EXPORT paragraph of your .def file?
    Also you [may] need to declare szDate as an LPSTR.



    "Pete Mitchell" <pmitchel@attachegroup.com> wrote:
    >
    >I keep getting the runtime error '49' "Bad DLL calling convention" error

    message
    >
    >when calling a function in a dll from my VB program.
    >It's C syntax is:
    >long Julian_Date(char *szDate)
    >
    >Here is my Declaration in the General Decs of a form:
    >Private Declare Function Julian_Date Lib "d:\Chariotts\qengine.dll" (ByVal
    >
    >sDate As String) As Long
    >
    >Here is the call to the function from a button click event:
    >Private Sub Command1_Click()
    > Dim retval As Long
    > Dim sDate As String
    >
    > sDate = "19990625"
    > retval = Julian_Date(sDate)
    >
    >End Sub
    >
    >I have also tried changing the function declaration to pass the parameter
    >ByRef with the same result.
    >
    >I have successfully called this function from Visual FoxPro so I figured
    >
    >that the function is exposed and available.
    >
    >What am I doing wrong ????
    >
    >Thanks in advance.
    >



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center