Results 1 to 3 of 3

Thread: Problems with functions from a DLL

  1. #1

    Thread Starter
    Member
    Join Date
    Aug 2003
    Posts
    63

    Unhappy Problems with functions from a DLL

    Hi all:

    I don't know if you has seen YACAS (Yet Another Computer Algebra System). It has a DLL with CAS functions and evaluation and I think it was created in Visual C++ 6.0.

    I would like to use that DLL (that comes with a .h header file with the functions declared to use in C++) in Visual Basic.

    I tryed to declare the functions like they are in the header file, but i get some errors and I don't know what do they mean.

    For example, there is a function called "yacas_init" that is declared as follow (in the C++ header file):

    Code:
    YACASDLL_API void yacas_init();
    I created a VB declaration for that function like:

    VB Code:
    1. Public Declare Sub YACAS_Init Lib "yacasdll.dll" Alias "yacas_init" ()

    When I call the function from VB I get no errors

    But, I have another function declared as follow:

    Code:
    YACASDLL_API void yacas_eval(char* expression);
    And I created a VB Declaration again for that function:

    VB Code:
    1. Public Declare Sub YACAS_Evaluation Lib "yacasdll.dll" Alias "yacas_eval" (ByRef strExpression As String)

    When I call that function from VB i get the following error:

    "Bad DLL calling convention (Error 49)"
    http://msdn.microsoft.com/library/de...allingConv.asp

    I looked for many ways to solve the problem, changed ByRef to ByVal, changing String to another data type, etc.

    Please help me with my problem.

    Keep in touch,

    Andy

  2. #2
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913

    Re: Problems with functions from a DLL

    Have you tried changing String to Any or Variant? I know you said you tried other data types, but didnt say which ones.
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  3. #3
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,803

    Re: Problems with functions from a DLL

    The String it's ByVal NOT ByRef, even though you use it to return data.
    VB Code:
    1. Public Declare Sub YACAS_Evaluation Lib "yacasdll.dll" Alias "yacas_eval" ([b]ByVal[/b] strExpression As String)

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