//先将库文件拷贝到项目文件夹
#include <iostream>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{ HINSTANCE hHandle;
typedef float (__stdcall * MY_FUNC)(float,float);
MY_FUNC func;
hHandle=LoadLibraryW(L"Mydll.dll");
if (hHandle==NULL)
{ cout<<"can not Load dll" <<endl;
return -1;
}
func=(float(__stdcall *)(float,float)) GetProcAddress(hHandle,"sum" );
if (func==NULL)
{ cout<<"can not find dll function" <<endl;
return -1;
}
cout<<func(1,2)<<endl;
FreeLibrary(hHandle);
system("pause");
return 0;
}