Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Export function

Export function

Scheduled Pinned Locked Moved C / C++ / MFC
c++comquestion
5 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    Jose Fco Bonnin
    wrote on last edited by
    #1

    I've created an ATL COM - dll - MFC Supported with the AppWizard and I added a function that return a CString. Now I want access to this function from another application to do it I type the next code. In the ATL COM ... __declspec(dllexport) CString GetEncodedText(CString p_sPlainText); ... In the other application ... hDLL = AfxLoadLibrary("BabMD5.dll"); if (hDLL != NULL) { typedef CString (CALLBACK *ENCODETEXT)(CString); ENCODETEXT p_encodeText = (ENCODETEXT)GetProcAddress( hDLL, _T("GetEncodedText")); if ( p_encodeText != NULL) { // -> NEVER GET HERE strEncoded = (*p_encodeText)( strPlain ); } AfxFreeLibrary( hDLL); } ... Anybody knows what's happen? Why I can't get the function? Thanks in advance

    M R 2 Replies Last reply
    0
    • J Jose Fco Bonnin

      I've created an ATL COM - dll - MFC Supported with the AppWizard and I added a function that return a CString. Now I want access to this function from another application to do it I type the next code. In the ATL COM ... __declspec(dllexport) CString GetEncodedText(CString p_sPlainText); ... In the other application ... hDLL = AfxLoadLibrary("BabMD5.dll"); if (hDLL != NULL) { typedef CString (CALLBACK *ENCODETEXT)(CString); ENCODETEXT p_encodeText = (ENCODETEXT)GetProcAddress( hDLL, _T("GetEncodedText")); if ( p_encodeText != NULL) { // -> NEVER GET HERE strEncoded = (*p_encodeText)( strPlain ); } AfxFreeLibrary( hDLL); } ... Anybody knows what's happen? Why I can't get the function? Thanks in advance

      M Offline
      M Offline
      Michael P Butler
      wrote on last edited by
      #2

      Why are you using a C export function in a COM DLL? It would make more sense to create an interface which has GetEncodedText as a method.

      HRESULT CTest::GetEncodedText(/*[in]*/BSTR PlainText, /*[out,retval]*/BSTR* EncodeText)

      Michael :-)

      J 1 Reply Last reply
      0
      • M Michael P Butler

        Why are you using a C export function in a COM DLL? It would make more sense to create an interface which has GetEncodedText as a method.

        HRESULT CTest::GetEncodedText(/*[in]*/BSTR PlainText, /*[out,retval]*/BSTR* EncodeText)

        Michael :-)

        J Offline
        J Offline
        Jose Fco Bonnin
        wrote on last edited by
        #3

        You are right, but this is my first adventure with COM and then I don't know how to access to the method through the other application

        C 1 Reply Last reply
        0
        • J Jose Fco Bonnin

          You are right, but this is my first adventure with COM and then I don't know how to access to the method through the other application

          C Offline
          C Offline
          Carlos Antollini
          wrote on last edited by
          #4

          If you wrote a ATL/COM Object, Only you need to Import the Dll functions... Cheers!!!:-D Carlos Antollini.

          1 Reply Last reply
          0
          • J Jose Fco Bonnin

            I've created an ATL COM - dll - MFC Supported with the AppWizard and I added a function that return a CString. Now I want access to this function from another application to do it I type the next code. In the ATL COM ... __declspec(dllexport) CString GetEncodedText(CString p_sPlainText); ... In the other application ... hDLL = AfxLoadLibrary("BabMD5.dll"); if (hDLL != NULL) { typedef CString (CALLBACK *ENCODETEXT)(CString); ENCODETEXT p_encodeText = (ENCODETEXT)GetProcAddress( hDLL, _T("GetEncodedText")); if ( p_encodeText != NULL) { // -> NEVER GET HERE strEncoded = (*p_encodeText)( strPlain ); } AfxFreeLibrary( hDLL); } ... Anybody knows what's happen? Why I can't get the function? Thanks in advance

            R Offline
            R Offline
            Rashid Thadha
            wrote on last edited by
            #5

            Don't mix standard DLL exports with In-Proc (DLL) COM Servers. It won't work !!!!

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups