日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程资源 > 编程问答 >内容正文

编程问答

DELPHI 7 动态链接库DLL断点调试

發(fā)布時(shí)間:2025/3/13 编程问答 25 豆豆
生活随笔 收集整理的這篇文章主要介紹了 DELPHI 7 动态链接库DLL断点调试 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

?DELPHI 7 動(dòng)態(tài)鏈接庫(kù)DLL斷點(diǎn)調(diào)試
???????? ?
馬根峰
???????? ?
(廣東聯(lián)合電子服務(wù)股份有限公司, 廣州 510300)

?

作者博客:

CSDN博客:http://blog.csdn.net/magenfeng

新浪博客:?http://blog.sina.com.cn/magenfeng

QQ空間:?http://user.qzone.qq.com/630414817

?

?
?


?

1??Delphi幾個(gè)經(jīng)典版本簡(jiǎn)介?
?

Delphi1995年的 1.0版本,發(fā)展到現(xiàn)在的最新的XE3版本,歷經(jīng)N多版本,但最為經(jīng)典的幾個(gè)版本個(gè)人覺得應(yīng)屬 7.02007 2010


?????? Delphi 7.0
應(yīng)該是Delphi用戶最多的版本。
?

Delphi 2007是功能就不多說了,歸根結(jié)底一句話,它是 AnsiString的最后一個(gè)版本,在Delphi 2007中,string類型映射為AnsiString char類型映射為AnsiCharPchar類型映射為PAnsiChar。所以DELPHI低版本的程序可以較輕松地遷移到DELPHI 2007版本。Delphi 2007也是Delphi程序員很容易上手的晚期版本。
?

Delphi2009開始起,到現(xiàn)在的Delphi XE3為止,都是 unicode版本。String類型映射為 UnicodeString而不是 AnsiStringChar類型映射為 WideCharPChar類型映射為 PWideChar

由于Delphi 7.02007 2010在界面上乃至功能上的一些變化,所以在動(dòng)態(tài)鏈接庫(kù)DLL斷點(diǎn)調(diào)試上,有較大的變化。在今后幾天的時(shí)間中,筆者會(huì)以三篇文章來分別詳細(xì)地介紹Delphi 72007 2010這三個(gè)版本中的DLL斷點(diǎn)調(diào)試技術(shù)。

?????? 本篇文章來詳細(xì)地介紹 Delphi 7中的動(dòng)態(tài)鏈接庫(kù)DLL斷點(diǎn)調(diào)試技術(shù)。

?

?

?


?

2????DELPHI 7DLL斷點(diǎn)設(shè)置與DLL調(diào)試
?

DELPHI 7.0以及以前的版本中,動(dòng)態(tài)鏈接庫(kù)的調(diào)試方法如下:
?

點(diǎn)擊菜單Run-->Parameters.打開Run Parameters窗口,如圖1所示。

?

1?點(diǎn)擊菜單Run-->Parameters.打開Run Parameters窗口
?

?

Run Parameters窗口中,在Host Application中填入宿主程序的完整路徑然后選擇,如圖2所示。

?
?

2?Run Parameters窗口中,點(diǎn)擊Browse選中宿主程序G:\Delphi_Dll_Debug\70\Magenf_Master\Delphi2007_Dll_Debug.exe

?
?

設(shè)置斷點(diǎn)后,輸入F9或者點(diǎn)擊Run-->Run來運(yùn)行宿主程序Delphi2007_Dll_Debug.exe,如圖3所示

?
?

???圖3?設(shè)置斷點(diǎn)后,輸入F9或者點(diǎn)擊Run-->Run來運(yùn)行宿主程序Delphi2007_Dll_Debug.exe
?

?

在主程序Delphi2007_Dll_Debug.exe窗口對(duì)應(yīng)的文本框中,輸入 12后,然后點(diǎn)擊按鈕“=”,即進(jìn)入DLL的斷點(diǎn)調(diào)試,如圖4所示。


?


??????????????????? 圖
4?進(jìn)入DLL的斷點(diǎn)調(diào)試

?

?


?

3????例子中的宿主程序及DLL程序代碼
?

-------宿主程序代碼-----

unit UDllDebug;

?

interface

?

uses

?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 hinst>0 then

??????begin

?????????????FDll_Add:=getprocaddress(hinst,pchar('Dll_Add'));

?

?????????????if FDll_Add<>nil 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 library's USES clause AND your project's (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 *.RES}

?

?

?

function???Dll_Add(int_1,int_2:integer):integer;stdcall;

var

????intSum:integer;

begin

???intSum:=int_1+int_2;

???result:=intSum;

end;

?

?

exports

???Dll_Add;

?

end.

?

-------DLL程序代碼-----

?



轉(zhuǎn)載于:https://www.cnblogs.com/wuyida/archive/2013/02/26/6300782.html

總結(jié)

以上是生活随笔為你收集整理的DELPHI 7 动态链接库DLL断点调试的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。