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