1.先編寫dll(add.dll)
2.然後編寫mfc對話方塊程式
在事件裡寫入:
typedef (winapi * testdll)(); //定地dll的使用
hinstance hmod;
hmod = ::loadlibrary ("mfcdll.dll"); //load dll
if(hmod==null)
...
testdll lpproc;
lpproc = (testdll)getprocaddress(hmod,"showint"); //呼叫dll函式showint
int i;
if(lpproc!=(testdll)null)
...lpproc = (testdll)getprocaddress(hmod, "showstr");//呼叫dll函式showstr
cstring str;
if (lpproc != (testdll)null )
...freelibrary(hmod);
別忘了把add.dll檔案放到mfc程式裡!
靜態載入dll和動態載入dll
一,首先編寫dll 建win32空dll工程 標頭檔案.h extern c declspec dllexport int max int a,int b extern c 解決函式名由於不同編譯器造成的名字匹配問題,通常c 編譯器編譯時會對函式進行改名,而c編譯器不會 extern c decls...
靜態載入dll和動態載入dll
一,首先編寫dll 建win32空dll工程 標頭檔案.h extern c declspec dllexport int max int a,int b extern c 解決函式名由於不同編譯器造成的名字匹配問題,通常c 編譯器編譯時會對函式進行改名,而c編譯器不會 extern c decls...
c 反射 動態載入dll簡單例子
假設已有元件classlibrarytest.dll,放置於程式目錄下。元件中classlibrarytest命名空間下有test類,類中有方法sum。下面示例就是動態載入元件並呼叫sum方法的簡例 1 static void main string args 2 classlibrarytest....