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. COM
  4. Export function

Export function

Scheduled Pinned Locked Moved COM
c++comquestion
2 Posts 2 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

    N 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

      N Offline
      N Offline
      Not Active
      wrote on last edited by
      #2

      If your DLL is COM this is not the way to do it. Think COM not WIN32. You need to create an instance then call the method. CMyObject MyObj; CoCreateInstance(__uuidof(myobj), .... ) BSTR bstrText HRESULT hr = MyObj->GetEncodedText(&bsrText); Notice also that you need a BSTR not CString. Since you are using ATL I'd also loose the MFC support, it doesn't get you anything but more overhead.

      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