In DLL
In sampDll.cpp
EXP int sum(int a , int b)
{ return (a+b);}
In sampDll.h
#define EXP extern "C" _declspec(dllexport)
In SampleDllapi.h
typedef int (FAR *sumfn) (int , int );
EXP int sum(int a , int b);
------------------------------------
In Exe
void CSampExeDlg::OnOK() { HMODULE hmodule = NULL; hmodule = ::LoadLibrary("SampDll.dll");
DWORD h ;
sumfn smp;
if ( hmodule ) { smp =(sumfn) GetProcAddress( hmodule,"sum");
}
int a = smp(2,7);
if ( hmodule ) {
::FreeLibrary(hmodule); }
CDialog::OnOK();}
Monday, August 25, 2008
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment