DLL除錯時的問題 |
答題得分者是:syntax
|
guardian635
一般會員 發表:19 回覆:6 積分:5 註冊:2009-11-21 發送簡訊給我 |
這是我寫的DLL源碼 以下是源碼除錯的時候跑出
[BCC32 Warning] File2.cpp(64): W8066 Unreachable code 第64行是 DllMyForm2 = new TForm3(Application); [code cpp] //--------------------------------------------------------------------------- #include #include #pragma hdrstop #include "Unit3.h" // TDllFrm 定义 //--------------------------------------------------------------------------- // Important note about DLL memory management when your DLL uses the // static version of the RunTime Library: // // If your DLL exports any functions that pass String objects (or structs/ // classes containing nested Strings) as parameter or function results, // you will need to add the library MEMMGR.LIB to both the DLL project and // any other projects that use the DLL. You will also need to use MEMMGR.LIB // if any other projects which use the DLL will be performing new or delete // operations on any non-TObject-derived classes which are exported from the // DLL. Adding MEMMGR.LIB to your project will change the DLL and its calling // EXE's to use the BORLNDMM.DLL as their memory manager. In these cases, // the file BORLNDMM.DLL should be deployed along with your DLL. // // To avoid using BORLNDMM.DLL, pass string information using "char *" or // ShortString parameters. // // If your DLL uses the dynamic version of the RTL, you do not need to // explicitly add MEMMGR.LIB as this will be done implicitly for you //--------------------------------------------------------------------------- USERES("File.res"); USEFORM("Unit3.cpp", DllFrm); //class __declspec(dllexport) __stdcall MyDllClass { //导出类 // public: // MyDllClass(); // void CreateAForm(); // / / TForm3* DllMyForm; //}; TForm3* DllMyForm2 ; //--------------------------------------------------------------------------- BOOL APIENTRY DllMain( HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved ) { switch (ul_reason_for_call) { /*case DLL_PROCESS_ATTACH: break; case DLL_THREAD_ATTACH: case DLL_THREAD_DETACH: case DLL_PROCESS_DETACH: */ TForm3* DllMyForm2 ; DllMyForm2 = new TForm3(Application); DllMyForm2->Show(); ShowMessage("0"); ShowMessage("1"); ShowMessage("0"); ShowMessage("0"); ShowMessage("0"); ShowMessage("0"); break; } return TRUE; } //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- void __stdcall CreateFromFunct() { DllMyForm2 = new TForm3(Application); DllMyForm2->Show(); } [/code] 編輯記錄
guardian635 重新編輯於 2010-02-28 17:37:47, 註解 無‧
|
aquarius
資深會員 發表:3 回覆:347 積分:330 註冊:2003-05-21 發送簡訊給我 |
|
syntax
尊榮會員 發表:26 回覆:1139 積分:1258 註冊:2002-04-23 發送簡訊給我 |
1.
第64行是 DllMyForm2 = new TForm3(Application); 有兩行 2. 只是警告你那一行,永遠執行不到 (你沒有 Export) ===================引 用 guardian635 文 章=================== 這是我寫的DLL源碼 以下是源碼除錯的時候跑出 [BCC32 Warning] File2.cpp(64): W8066 Unreachable code 第64行是 DllMyForm2 = new TForm3(Application); [code cpp] //--------------------------------------------------------------------------- #include #include #pragma hdrstop #include "Unit3.h" // TDllFrm 定义 //--------------------------------------------------------------------------- // Important note about DLL memory management when your DLL uses the // static version of the RunTime Library: // // If your DLL exports any functions that pass String objects (or structs/ // classes containing nested Strings) as parameter or function results, // you will need to add the library MEMMGR.LIB to both the DLL project and // any other projects that use the DLL. You will also need to use MEMMGR.LIB // if any other projects which use the DLL will be performing new or delete // operations on any non-TObject-derived classes which are exported from the // DLL. Adding MEMMGR.LIB to your project will change the DLL and its calling // EXE's to use the BORLNDMM.DLL as their memory manager. In these cases, // the file BORLNDMM.DLL should be deployed along with your DLL. // // To avoid using BORLNDMM.DLL, pass string information using "char *" or // ShortString parameters. // // If your DLL uses the dynamic version of the RTL, you do not need to // explicitly add MEMMGR.LIB as this will be done implicitly for you //--------------------------------------------------------------------------- USERES("File.res"); USEFORM("Unit3.cpp", DllFrm); //class __declspec(dllexport) __stdcall MyDllClass { //导出类 // public: // MyDllClass(); // void CreateAForm(); /// / TForm3* DllMyForm; //}; TForm3* DllMyForm2 ; //--------------------------------------------------------------------------- BOOL APIENTRY DllMain( HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved ) { switch (ul_reason_for_call) { /*case DLL_PROCESS_ATTACH: break; case DLL_THREAD_ATTACH: case DLL_THREAD_DETACH: case DLL_PROCESS_DETACH: */ TForm3* DllMyForm2 ; DllMyForm2 = new TForm3(Application); DllMyForm2->Show(); ShowMessage("0"); ShowMessage("1"); ShowMessage("0"); ShowMessage("0"); ShowMessage("0"); ShowMessage("0"); break; } return TRUE; } //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- void __stdcall CreateFromFunct() { DllMyForm2= new TForm3(Application); DllMyForm2->Show(); } [/code] |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |