CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Jun 2001
    Posts
    36

    error: bad calling dll convention

    hi you all doing

    i have a dll defined like this in access module

    Public Declare Function GenerateLicenceID Lib "C:\Final\bin\vproc.dll" Alias "?GenerateLicenceID@@YA?AVCString@@V1@H@Z" (sBaseID As String, duration As Integer) As String


    than i have a function that calls it in one of the forms

    Dim SerKey As String
    Dim UnKey As String
    Dim sTerm As Integer

    sTerm = [Term].Value
    SerKey = [Lic_Key].Value

    UnKey = GenerateLicenceID(SerKey, sTerm)

    [Unlock_Key].Value = UnKey

    but as i run it i get bad calling dll convention

    i use the alias feature because that is how it is called after exporting it in c++


  2. #2

    Re: error: bad calling dll convention

    1) R U sure as string the return value of API?
    2) maybe that the function in lib is not declare as __stdcall...

    <center>
    <HR width=80%>
    <img src='http://web.tiscali.it/bertaplanet/im...ertaplanet.gif'>
    </center>

  3. #3
    Join Date
    Oct 2004
    Posts
    481

    Re: error: bad calling dll convention

    YES!!! This post has helped me solved my problem. I forgot to put __stdcall after declspec(dllexport).

    Thanks GetFree

  4. #4
    Join Date
    Aug 2004
    Location
    Bucharest, Romania... sometimes
    Posts
    1,039

    Post Re: error: bad calling dll convention

    Quote Originally Posted by MSDN
    Warning If you change the function name, class, calling convention, return type, or any parameter, the decorated name is no longer valid. You must get the new version of the function name and use it everywhere the decorated name is specified.
    "?GenerateLicenceID@@YA?AVCString@@V1@H@Z" is not guaranteed to remain the same. To get your function exported with an undecorated name you should use a *.def file in the C++ project building the dll.
    Sample content of a *.def file:
    Code:
    ;	MyDLL.def
    ;	The LIBRARY entry must be same as the name of your DLL
    
    LIBRARY      "MyDLL"
    DESCRIPTION  "What is my library doing"
    
    EXPORTS
    	VisibleName1
    	VisibleName2=InternalName2
    	VisibleName3	@1
    	VisibleName4	@2	NONAME
    Regards,
    Bogdan Apostol
    ESRI Developer Network

    Compilers demystified - Function pointers in Visual Basic 6.0
    Enables the use of function pointers in VB6 and shows how to embed native code in a VB application.

    Customize your R2H
    The unofficial board dedicated to ASUS R2H UMPC owners.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured