locked
atl dll RRS feed

  • Question

  • Hi All,

    This is sample atl dll function

    STDMETHODIMP Catl2::add(long a, long b, long *c)
    {
        AFX_MANAGE_STATE(AfxGetStaticModuleState())

        // TODO: Add your implementation code here
        *c=a+b;

        return S_OK;
    }

    how i can  load this dll(sampleatl.dll) to mfc dialog application..

    am loading like AfxLoadLibrary("sample_atl2.dll");

    if( hDLL == NULL )
            AfxMessageBox("Could not load the DLL");
        else
        {
            lpGetNumber = (LPGETNUMBER)GetProcAddress(hDLL, "add");
        }

        if( lpGetNumber == NULL )
        {
            AfxMessageBox("Could not find the DLL");
            return;
        }

    int x;

    lpGetNumber(4,5,&x)----->this is correct way to receive  out valu from dll

    please explain ....


    umapathi

    Thursday, July 5, 2012 7:31 AM

Answers

  • The example add() function is really an object method, but you try to access it like a regular function.  So No.

    The first piece of code (the add() method) looks like taken from an ATL ActiveX DLL.  Don't create an ActiveX DLL.  Create a simple DLL with good old regular functions.


    Jose R. MCP
    Code Samples

    • Proposed as answer by Helen Zhao Friday, July 6, 2012 6:43 AM
    • Marked as answer by Helen Zhao Thursday, July 12, 2012 5:26 AM
    Thursday, July 5, 2012 1:49 PM

All replies

  • The example add() function is really an object method, but you try to access it like a regular function.  So No.

    The first piece of code (the add() method) looks like taken from an ATL ActiveX DLL.  Don't create an ActiveX DLL.  Create a simple DLL with good old regular functions.


    Jose R. MCP
    Code Samples

    • Proposed as answer by Helen Zhao Friday, July 6, 2012 6:43 AM
    • Marked as answer by Helen Zhao Thursday, July 12, 2012 5:26 AM
    Thursday, July 5, 2012 1:49 PM
  • If you want consume ATL DLL from MFc, you can follow the following process.

    http://www.devarticles.com/c/a/Cplusplus/Your-First-COM-Client-In-Visual-C-plus/2/


    Thanks and Regards Selvam http://www15.brinkster.com/selvamselvam/

    • Proposed as answer by Helen Zhao Thursday, July 12, 2012 5:26 AM
    Thursday, July 5, 2012 6:33 PM