....oops I goofed sorry.. Here it is again
Code:
//*****************************************
//in the DLL .h file
void DisplayAppName();
int Multiply(int x, int y);
//*****************************************
//in the DLL cpp file
void DisplayAppName()
{
AFX_MANAGE_STATE(AfxGetStaticModuleState() );
CString str = AfxGetAppName();
AfxMessageBox( str );
}
int Multiply(int x, int y)
{
return x * y;
}
//****************************************
//In the client program (driver program)
void CDllTestDlg::OnButton1()
{
FARPROC pfn;
char buffer[255];
CString s;
GetCurrentDirectory(255, buffer);
s = buffer;
s.TrimRight("\\");
s += ("\\DllProj.dll");
HMODULE hm = LoadLibrary( s );
if( hm != NULL )
{
CString s1;
//this works fine
pfn = GetProcAddress(hm, "DisplayAppName");
if( pfn != NULL )
pfn();
else
{
s1.Format("Error %d", GetLastError());
MessageBox( s1 );
}
//** this does not work
//**i also tried "Multiply(int x, int y)
//** i also tried declaring my own pointer to function
//int (*multi)(int x, int y);
//multi = GetProcAdress(hm, "Multiply");
pfn = GetProcAddress(hm, "Multiply");
if( pfn != NULL )
{
s1.Format("2 * 2 = %d", pfn());
MessageBox( s1 );
}
}
}