????????????????????校?????????????????????些??????????????邪??????????谐????????DLL???????????????????????????????????????????????????械?????????????????谩?Windows API?械????泻???????????DLL?小???????3???????DLL??Kernel32.dll?????????????????妤�??????????????????User32.dll???????????????????????????绱�(x矛)????????????????????????????GDI32.dll?????????????????????????????????

???????????????????????

????1?????????

????2?????????

?????????????????????????????????

?????????????????????????????

int _stdcall add(int a??int b)
{
 return a+b;
}

int _stdcall subtract(int a??int b)
{
 return a-b;
}

????????DLL????????????????????????????????????娑�?????????_declspec(dllexport)

_declspec(dllexport) int _stdcall add(int a??int b)
{
 return a+b;
}

_declspec(dllexport) int _stdcall subtract(int a??int b)
{
 return a-b;
}

???????????????槎�?????.def???械???

????LIBRARY DllName
????EXPORTS
????add
????subtract

????????????????????????????锟�??????慰?C++???????????????

???????????????????????????????lib????????dll???????????lib????????????

?????????????????????????????????????(?????????.LIB)??????t?????????锟�??????????????????????????????懈?????些????????????????????贸????????????????????????????????(.EXE???)??

????????????????????????????????????????????DLL????????????DLL???????????????????????DLL??????????????????????????????????????????????????DLL?械??????????????????????????????校??????械???????????DLL??????DLL?械??????????

??????????????伞?

???????????????????????????????????????????????????些????????????????????????????????lib?????????????????????????? ??????->????->???????????????????????

???????????????DLL??????????????????????DDL???????????????????????????????????DLL?械???????????

????????????????????????????????????LoadLibrary

??????MSDN?校?

????HMODULE WINAPI LoadLibrary(
????__in  LPCTSTR lpFileName
????);

????Maps the specified executable module into the address space of the calling process.

????????????????????????????????榈�???y????????????宸�?????锟�?

????MFC????

HINSTANCE hInst;
hInst=LoadLibrary("Dll3.dll");//??Dll3??????????????
typedef int (/*_stdcall*/ *addFunPro)(int a??int b);//???????????????????????????????????????????婧�?????
addFunPro AddFun=(addFunPro)GetProcAddress(hInst??MAKEINTRESOURCE(1));//??????????????
if(!AddFun)
{
 MessageBox("??????????????");
 return;
}
CString str;
str.Format("5+3=%d"??AddFun(5??3));//???????????????屑??????
MessageBox(str);
FreeLibrary(hInst);