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
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 :-)
-
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 :-)
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
-
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
If you wrote a ATL/COM Object, Only you need to Import the Dll functions... Cheers!!!:-D Carlos Antollini.
-
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
Don't mix standard DLL exports with In-Proc (DLL) COM Servers. It won't work !!!!