CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    May 2011
    Posts
    3

    help to make dll file

    I need to make dll file for computing user defined function in Lindo Lingo. I need to implement two new functions, but I can make only one myuser.dll file for use in Lingo.
    But, talking with people from Lindo, it is possible to make two argument myuser.dll function, with first first argument as a "branching" variable. for example, For example,
    @USER( 1, 2.4)
    might compute the sin of 2.4, while
    @USER( 2, 2.4)
    would compute the cosine of 2.4. The first argument of 1 implies return the sin, while a first argument of 2 implies return the cosine.

    My question is how to do that, because I am new to Vc++.
    Thanks in advance,
    Aleksandar

  2. #2
    Join Date
    Feb 2002
    Posts
    4,640

    Re: help to make dll file

    Code:
    double MyFunc (int nFunc, double fparam)
    {
       double  fRetVal = 0.0;
       switch (nFunc)
       {
          case 1:
              fRetVal = sin(2.4);
              break;
          case 2:
              fRetVal = sin(2.4);
              break;
       }
       return fRetVal;
    }
    Is one way...

    Viggy

  3. #3
    Join Date
    May 2011
    Posts
    3

    Re: help to make dll file

    This way doesn work. I try it.
    I have example for one function from Lingo manual (i.e. sqroot):
    // routines for the DLL.
    //#include "stdafx.h"
    #include "sqroot.h"
    #ifdef _DEBUG
    #define new DEBUG_NEW
    #undef THIS_FILE
    static char THIS_FILE[] = __FILE__;
    #endif
    /////////////////////////////////////////////////////
    // CSqrootApp
    BEGIN_MESSAGE_MAP(CSqrootApp, CWinApp)
    //{{AFX_MSG_MAP(CSqrootApp)
    //NOTE-the ClassWizard will add and
    // remove mapping macros here.
    // DO NOT EDIT what you see in these
    // blocks of generated code!
    //}}AFX_MSG_MAP
    END_MESSAGE_MAP()
    CSqrootApp::CSqrootApp()
    {
    // The constructor
    // Remove next line for a "quiet" version
    // of MyUser.DLL
    AfxMessageBox("@USER DLL installed");
    }
    CSqrootApp theApp;
    #include <math.h>
    extern "C" __declspec(dllexport)
    void MyUser(int* pnNumberOfArgs,
    double* pdArgs, double* dResult)
    {
    // This is an @USER routine callable by LINGO. In
    // this particular case we simply take the
    // square root of the first argument.
    *dResult = sqrt(*pdArgs);
    }
    I contact them and they said that it is possible to use multiple functions with @USER by writing and compiling each function as a separate subroutine and taking an argument to @USER as the index number of the subroutine that you want to branch to.
    Is there any chanse to see an example of how to do that, or explanation how to do that, because I am new in VC++.
    Thanks

  4. #4
    Join Date
    May 2011
    Posts
    3

    Re: help to make dll file

    I tried And I have no luck. They said that it is possible to use multiple functions with @USER by writing and compiling each function as a
    separate subroutine and taking an argument to @USER as the index number of the subroutine that you
    want to branch to.
    I am interested how to do that.
    Thanks in advance.

  5. #5
    Join Date
    May 2011
    Posts
    5

    Re: help to make dll file

    MrViggy already posted how.

    Do you encounter any problems while compiling your dll?

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