已閱讀5頁(yè),還剩8頁(yè)未讀, 繼續(xù)免費(fèi)閱讀
版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
DELPHI 2010 動(dòng)態(tài)鏈接庫(kù)DLL斷點(diǎn)調(diào)試馬根峰 ( 廣東聯(lián)合電子服務(wù)股份有限公司, 廣州 510300)摘要:本文詳細(xì)介紹了Delphi 2010中的動(dòng)態(tài)鏈接庫(kù)DLL斷點(diǎn)調(diào)試技術(shù)關(guān)鍵詞: DELPHI 2010;Dll斷點(diǎn)調(diào)試;1 Delphi 幾個(gè)經(jīng)典版本簡(jiǎn)介 Delphi從1995年的 1.0版本,發(fā)展到現(xiàn)在的最新的XE3版本,歷經(jīng)N多版本,但最為經(jīng)典的幾個(gè)版本個(gè)人覺(jué)得應(yīng)屬 7.0、2007和 2010。Delphi 7.0應(yīng)該是Delphi用戶最多的版本。Delphi 2007是功能就不多說(shuō)了,歸根結(jié)底一句話,它是 AnsiString的最后一個(gè)版本,在Delphi 2007中,string類(lèi)型映射為 AnsiString ,char類(lèi)型映射為 AnsiChar,Pchar類(lèi)型映射為 PAnsiChar。所以DELPHI低版本的程序可以較輕松地遷移到DELPHI 2007版本。Delphi 2007也是Delphi程序員很容易上手的晚期版本。從Delphi2009開(kāi)始起,到現(xiàn)在的Delphi XE3為止,都是 unicode 版本。String 類(lèi)型映射為 UnicodeString 而不是 AnsiString ,Char 類(lèi)型映射為 WideChar,PChar 類(lèi)型映射為 PWideChar。 由于Delphi 7.0、2007和 2010在界面上乃至功能上的一些變化,所以在動(dòng)態(tài)鏈接庫(kù)DLL斷點(diǎn)調(diào)試上,有較大的變化。在今后幾天的時(shí)間中,筆者會(huì)以三篇文章來(lái)分別詳細(xì)地介紹Delphi 7.0、2007和 2010這三個(gè)版本中的DLL斷點(diǎn)調(diào)試技術(shù)。本篇文章來(lái)詳細(xì)地介紹 Delphi 2010中的動(dòng)態(tài)鏈接庫(kù)DLL斷點(diǎn)調(diào)試技術(shù)。2 DELPHI 2010的DLL斷點(diǎn)設(shè)置與DLL調(diào)試在DELPHI 7.0以及以前的版本中,動(dòng)態(tài)鏈接庫(kù)的調(diào)試方法如下:點(diǎn)擊菜單Run-Parameters.打開(kāi)Run Parameters窗口,如圖1所示。 圖1 點(diǎn)擊菜單Run-Parameters.打開(kāi)Run Parameters窗口設(shè)置圖中斷點(diǎn),然后點(diǎn)擊F9或者RunRun來(lái)運(yùn)行宿主程序Delphi2007_Dll_Debug.exe,但發(fā)現(xiàn)斷點(diǎn)無(wú)效,如圖2所示:圖2 設(shè)置斷點(diǎn)后,運(yùn)行宿主程序 Delphi2007_Dll_Debug.exe,斷點(diǎn)無(wú)效 點(diǎn)擊Project-Options.,在Project Options窗口中,在Delphi CompilerCompiling屬性頁(yè)中將Debug information設(shè)置為T(mén)rue,如圖3所示:圖3 在Delphi CompilerCompiling屬性頁(yè)中將Debug information設(shè)置為T(mén)rue點(diǎn)擊Project-Options.,在Project Options窗口中,在Delphi CompilerLinking屬性頁(yè)中將Debug information和Include remote debug symbols兩項(xiàng)設(shè)置為T(mén)rue,如圖4所示:圖4 將Debug information和Include remote debug symbols兩項(xiàng)設(shè)置為T(mén)rue運(yùn)行宿主程序Delphi2007_Dll_Debug.exe,斷點(diǎn)還是無(wú)效,如圖5所示:圖5 運(yùn)行宿主程序 Delphi2007_Dll_Debug.exe,發(fā)現(xiàn)斷點(diǎn)還是無(wú)效切換到Delphi的DLL工程文件上,點(diǎn)擊ctrl+alt+M,跳出一個(gè)名叫Modules的窗體來(lái)。左上角顯示了宿主程序本身及其它所調(diào)用的資源。找到動(dòng)態(tài)鏈接庫(kù) Magenf_Detail.dll項(xiàng),發(fā)現(xiàn)目錄沒(méi)有指向當(dāng)前DLL所在的目錄。點(diǎn)擊鼠標(biāo)右鍵,選中菜單項(xiàng)“Reload Symbol Table”如圖6所示:圖6 打開(kāi)Modules屬性頁(yè),找到Magenf_Detail.dll項(xiàng),點(diǎn)擊鼠標(biāo)右鍵,Reload Symbol Table重新設(shè)置動(dòng)態(tài)鏈接庫(kù)Magenf_Detail.dll 的位置,選中當(dāng)前DLL工程Magenf_Detail所在目錄的動(dòng)態(tài)鏈接庫(kù)Magenf_Detail.dll文件,如圖7所示:圖7 打開(kāi)Modules屬性頁(yè),找到Magenf_Detail.dll項(xiàng),點(diǎn)擊鼠標(biāo)右鍵,Reload Symbol Table,重新設(shè)置它的位置 然后切換到Delphi的屬性頁(yè)Magenf_Detail,發(fā)現(xiàn)斷點(diǎn)生效,如圖8所示:圖8 點(diǎn)擊屬性頁(yè)Magenf_Detail,發(fā)現(xiàn)斷點(diǎn)生效在Delphi2007_Dll_Debug.exe,輸入 1和2 后點(diǎn)擊銨鈕“=”,如圖9所示:圖9 在Delphi2007_Dll_Debug.exe,輸入 1和2 后點(diǎn)擊銨鈕“=” 進(jìn)入DLL斷點(diǎn)調(diào)試,如圖10所示:圖10 進(jìn)入DLL的斷點(diǎn)調(diào)試3 例子中的宿主程序及DLL程序代碼-宿主程序代碼-unit UDllDebug;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls, Buttons, Contnrs , ActiveX, StrUtils ;type TDll_Add=function(int_1,int_2:integer):integer;stdcall; TfrmDllDebug = class(TForm) Edit1: TEdit; Edit2: TEdit; Label1: TLabel; Edit3: TEdit; BtnAdd: TButton; procedure FormCreate(Sender: TObject); procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure BtnAddClick(Sender: TObject); private Private declarations public Public declarations HInst:Thandle; FDll_Add:TFarProc; functionDll_Add:TDll_Add; /aForeThread:MuliThread; end;var frmDllDebug: TfrmDllDebug;implementation $R *.dfm procedure TfrmDllDebug.FormCreate(Sender: TObject);begin hinst:=loadlibrary(Magenf_Detail.dll); if hinst0 then begin FDll_Add:=getprocaddress(hinst,pchar(Dll_Add); if FDll_Addnil then functionDll_Add:=TDll_Add(FDll_Add) else messagedlg(Fatal error! Function not be found!,mtWarning, mbYes, 0) ; end else messagedlg(Fatal error! Magenf_Detail.dll not be found!,mtWarning, mbYes, 0) ;end;procedure TfrmDllDebug.FormClose(Sender: TObject; var Action: TCloseAction);begin try freelibrary(hinst); except end;end; procedure TfrmDllDebug.BtnAddClick(Sender: TObject);var int1,int2,int_return:integer;begin int1:=strToInt(edit1.Text); int2:=strToInt(edit2.Text); int_return:=functionDll_Add(int1,int2); edit3.Text :=intToStr(int_return);end;end.-宿主程序代碼-DLL程序代碼-library Magenf_Detail; Important note about DLL memory management: ShareMem must be the first unit in your librarys USES clause AND your projects (select Project-View Source) USES clause if your DLL exports any procedures or functions that pass strings as parameters or function results. This applies to all strings passed to and from your DLL-even those that are nested in records and classes. ShareMem is the interface unit to the BORLNDMM.DLL shared memory manager, which must be deployed along with your DLL. To avoid using BORLNDMM.DLL, pass string information using PChar or ShortString parameters. uses SysUtils,Classes;$R *.RESfunction Dll_Add(int_1,int_2:integer):integer;stdcall;var intS
溫馨提示
- 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 粉末銷(xiāo)售合同范本
- 云浮市2024廣東省云浮市機(jī)關(guān)事業(yè)單位招聘緊缺人才20人中山大學(xué)廣州校區(qū)南校筆試歷年參考題庫(kù)典型考點(diǎn)附帶答案詳解(3卷合一)
- 注冊(cè)建造師面試題集
- 中航集團(tuán)航空醫(yī)療設(shè)備管理人員筆試模擬試卷含答案
- 電力行業(yè)子公司負(fù)責(zé)人面試題庫(kù)
- 2025年區(qū)域公共衛(wèi)生應(yīng)急體系可行性研究報(bào)告
- 2025年虛擬房產(chǎn)交易平臺(tái)項(xiàng)目可行性研究報(bào)告
- 2025年居家辦公模式的經(jīng)濟(jì)影響可行性研究報(bào)告
- 2025年薄膜太陽(yáng)能電池生產(chǎn)項(xiàng)目可行性研究報(bào)告
- 2025年農(nóng)業(yè)產(chǎn)業(yè)鏈整合項(xiàng)目可行性研究報(bào)告
- 2025年國(guó)家開(kāi)放大學(xué)(電大)《民法學(xué)》期末考試復(fù)習(xí)試題及答案解析
- 集成電路芯片設(shè)計(jì)企業(yè)組織架構(gòu)詳解
- DB1303∕T381-2024 神經(jīng)外科圍手術(shù)期護(hù)理指南
- 靜脈血栓的評(píng)估與處理
- 藿香中藥課件
- 痰濕體質(zhì)課件
- 2025ESC心肌炎和心包炎管理指南解讀
- 十年(2016-2025)高考英語(yǔ)真題分類(lèi)匯編:專(zhuān)題22 語(yǔ)法填空(全國(guó))(原卷版)
- 學(xué)生實(shí)習(xí)協(xié)議模板
- 2025浙江金華義烏市水處理有限責(zé)任公司招聘5人考試參考題庫(kù)及答案解析
- (正式版)DB61∕T 5062-2023 《擠密樁法處理地基技術(shù)規(guī)程》
評(píng)論
0/150
提交評(píng)論