C++???????????????梅??
???????????? ???????[ 2013/5/13 10:20:28 ] ????????
????????????????????校?????????????????????些??????????????邪??????????谐????????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);
??????

???路???
??????????????????
2023/3/23 14:23:39???写?貌??????????
2023/3/22 16:17:39????????????????????些??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???路???????路
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11