MFC APP中使用MFC DLL(用C )

2021-06-26 00:42:01 字數 917 閱讀 9507

先寫dll檔案:

選擇mfc擴充套件dll。

在.def檔案中加入:

; mfcdbstore_1.def : declares the module parameters for the dll.

library      "mfcdbstore_1"

description  'mfcdbstore_1 windows dynamic link library'

exports

; explicit exports can go here

mfcdbstore;      //這個是需要匯出的名字

然後再cpp檔案中加入:

void apientry mfcdbstore(); //extern "c" void apientry msg();       //去掉extern,以c++的方式編譯

然後:class a            //寫自己需要的類

~a()

};void apientry mfcdbstore()       //建立物件

至此,dll編寫完。開始編寫mfc 單文件程式:

選擇類檢視,新增訊息處理函式,選擇滑鼠左鍵按下。

新增**:

void cmfcdbstore_2view::onlbuttondown(uint nflags, cpoint point)

lpfn=getprocaddress(hinst,"mfcdbstore");//取得dll匯出函式的位址

if (lpfn==null)

lpfn();//執行dll函式

freelibrary(hinst);//釋放dllsharemfcdill.dll

cview::onlbuttondown(nflags, point);

}嗯。按下滑鼠就可以看到  預設的構造和析構被呼叫。

傳送郵件 MFC dll 測試中使用

mfc dll 使用mapi int sendemail const char address,const char subject,const char text else send the message freelibrary hmapiinst return iresult 函式呼叫 ext...

程序中使用委託(程序中使用程序)

delegate void setlablevisible bool bl 隱藏控制項的委託 設定進度控制項的隱藏顯示 委託 private void setvisible bool bl else this setvisible false 隱藏狀態控制項 當在程序中需要呼叫另外乙個程序的控制項的...

php中使用mysql介紹 PHP中使用MySQL

mysql資料庫的擴充套件 擴充套件庫基本功能相似,用法基本相同,會增加一些新的特性 mysqli擴充套件庫 只能對mysql資料庫操作 pdo擴充套件 可以操作很多態別的資料庫 wamp下修改mysql資料庫密碼 三者在建立連線上的比較 pdo需要四個引數,除了資料庫管理員名稱 密碼 host 還...