全國最多中醫師線上諮詢網站-台灣中醫網
發文 回覆 瀏覽次數:1600
推到 Plurk!
推到 Facebook!

DLL除錯時的問題

答題得分者是:syntax
guardian635
一般會員


發表:19
回覆:6
積分:5
註冊:2009-11-21

發送簡訊給我
#1 引用回覆 回覆 發表時間:2010-02-28 17:36:21 IP:122.117.xxx.xxx 訂閱
這是我寫的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

發送簡訊給我
#2 引用回覆 回覆 發表時間:2010-02-28 22:49:38 IP:114.43.xxx.xxx 訂閱
form 是宣告在 DLL 中的嗎?
如果是的話, 在 DLL 中沒有 Application, 這個系統物件只有在 EXE 中才存在.

建議可以把參數換成 nil , 或是要重新取得 application 的 handle.

------
水瓶男的blog: http://791909.blogspot.com
syntax
尊榮會員


發表:26
回覆:1139
積分:1258
註冊:2002-04-23

發送簡訊給我
#3 引用回覆 回覆 發表時間:2010-03-01 09:34:19 IP:59.125.xxx.xxx 訂閱
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]

系統時間:2024-05-19 1:04:09
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!