DELPHI 动态链接库DLL断点调试Word文件下载.docx

上传人:b****2 文档编号:975890 上传时间:2023-04-29 格式:DOCX 页数:15 大小:1.69MB
下载 相关 举报
DELPHI 动态链接库DLL断点调试Word文件下载.docx_第1页
第1页 / 共15页
DELPHI 动态链接库DLL断点调试Word文件下载.docx_第2页
第2页 / 共15页
DELPHI 动态链接库DLL断点调试Word文件下载.docx_第3页
第3页 / 共15页
DELPHI 动态链接库DLL断点调试Word文件下载.docx_第4页
第4页 / 共15页
DELPHI 动态链接库DLL断点调试Word文件下载.docx_第5页
第5页 / 共15页
DELPHI 动态链接库DLL断点调试Word文件下载.docx_第6页
第6页 / 共15页
DELPHI 动态链接库DLL断点调试Word文件下载.docx_第7页
第7页 / 共15页
DELPHI 动态链接库DLL断点调试Word文件下载.docx_第8页
第8页 / 共15页
DELPHI 动态链接库DLL断点调试Word文件下载.docx_第9页
第9页 / 共15页
DELPHI 动态链接库DLL断点调试Word文件下载.docx_第10页
第10页 / 共15页
DELPHI 动态链接库DLL断点调试Word文件下载.docx_第11页
第11页 / 共15页
DELPHI 动态链接库DLL断点调试Word文件下载.docx_第12页
第12页 / 共15页
DELPHI 动态链接库DLL断点调试Word文件下载.docx_第13页
第13页 / 共15页
DELPHI 动态链接库DLL断点调试Word文件下载.docx_第14页
第14页 / 共15页
DELPHI 动态链接库DLL断点调试Word文件下载.docx_第15页
第15页 / 共15页
亲,该文档总共15页,全部预览完了,如果喜欢就下载吧!
下载资源
资源描述

DELPHI 动态链接库DLL断点调试Word文件下载.docx

《DELPHI 动态链接库DLL断点调试Word文件下载.docx》由会员分享,可在线阅读,更多相关《DELPHI 动态链接库DLL断点调试Word文件下载.docx(15页珍藏版)》请在冰点文库上搜索。

DELPHI 动态链接库DLL断点调试Word文件下载.docx

String类型映射为UnicodeString而不是AnsiString,Char类型映射为WideChar,PChar类型映射为PWideChar。

由于Delphi7.0、2007和2010在界面上乃至功能上的一些变化,所以在动态链接库DLL断点调试上,有较大的变化。

在今后几天的时间中,笔者会以三篇文章来分别详细地介绍Delphi7.0、2007和2010这三个版本中的DLL断点调试技术。

本篇文章来详细地介绍Delphi2010中的动态链接库DLL断点调试技术。

2DELPHI2010的DLL断点设置与DLL调试

在DELPHI7.0以及以前的版本中,动态链接库的调试方法如下:

点击菜单Run-->

Parameters.打开RunParameters窗口,如图1所示。

图1点击菜单Run-->

Parameters.打开RunParameters窗口

设置图中断点,然后点击F9或者Run—Run来运行宿主程序Delphi2007_Dll_Debug.exe,但发现断点无效,如图2所示:

图2设置断点后,运行宿主程序Delphi2007_Dll_Debug.exe,断点无效

点击Project-->

Options..,在ProjectOptions窗口中,在DelphiCompiler—Compiling属性页中将Debuginformation设置为True,如图3所示:

图3在DelphiCompiler—Compiling属性页中将Debuginformation设置为True

Options..,在ProjectOptions窗口中,在DelphiCompiler—Linking属性页中将Debuginformation和Includeremotedebugsymbols两项设置为True,如图4所示:

图4将Debuginformation和Includeremotedebugsymbols两项设置为True

运行宿主程序Delphi2007_Dll_Debug.exe,断点还是无效,如图5所示:

图5运行宿主程序Delphi2007_Dll_Debug.exe,发现断点还是无效

切换到Delphi的DLL工程文件上,点击ctrl+alt+M,跳出一个名叫Modules的窗体来。

左上角显示了宿主程序本身及其它所调用的资源。

找到动态链接库Magenf_Detail.dll项,发现目录没有指向当前DLL所在的目录。

点击鼠标右键,选中菜单项“ReloadSymbolTable…”如图6所示:

图6打开Modules属性页,找到Magenf_Detail.dll项,点击鼠标右键,ReloadSymbolTable…

重新设置动态链接库Magenf_Detail.dll的位置,选中当前DLL工程Magenf_Detail所在目录的动态链接库Magenf_Detail.dll文件,如图7所示:

图7打开Modules属性页,找到Magenf_Detail.dll项,点击鼠标右键,ReloadSymbolTable…,重新设置它的位置

然后切换到Delphi的属性页Magenf_Detail,发现断点生效,如图8所示:

图8点击属性页Magenf_Detail,发现断点生效

在Delphi2007_Dll_Debug.exe,输入1和2后点击铵钮“=”,如图9所示:

图9在Delphi2007_Dll_Debug.exe,输入1和2后点击铵钮“=”

进入DLL断点调试,如图10所示:

图10进入DLL的断点调试

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

-------宿主程序代码-----

unitUDllDebug;

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:

Label1:

TLabel;

Edit3:

BtnAdd:

TButton;

procedureFormCreate(Sender:

TObject);

procedureFormClose(Sender:

TObject;

varAction:

TCloseAction);

procedureBtnAddClick(Sender:

private

{Privatedeclarations}

public

{Publicdeclarations}

HInst:

Thandle;

FDll_Add:

TFarProc;

functionDll_Add:

TDll_Add;

//aForeThread:

MuliThread;

end;

var

frmDllDebug:

TfrmDllDebug;

implementation

{$R*.dfm}

 

procedureTfrmDllDebug.FormCreate(Sender:

begin

hinst:

=loadlibrary('

Magenf_Detail.dll'

);

ifhinst>

0then

begin

=getprocaddress(hinst,pchar('

Dll_Add'

));

ifFDll_Add<

>

nilthen

=TDll_Add(FDll_Add)

else

messagedlg('

Fatalerror!

Functionnotbefound!

'

mtWarning,[mbYes],0);

end

else

Magenf_Detail.dllnotbefound!

end;

procedureTfrmDllDebug.FormClose(Sender:

begin

try

freelibrary(hinst);

except

procedureTfrmDllDebug.BtnAddClick(Sender:

int1,int2,int_return:

int1:

=strToInt(edit1.Text);

int2:

=strToInt(edit2.Text);

int_return:

=functionDll_Add(int1,int2);

edit3.Text:

=intToStr(int_return);

end.

-------DLL程序代码-----

libraryMagenf_Detail;

{ImportantnoteaboutDLLmemorymanagement:

ShareMemmustbethe

firstunitinyourlibrary'

sUSESclauseANDyourproject'

s(select

Project-ViewSource)USESclauseifyourDLLexportsanyproceduresor

functionsthatpassstringsasparametersorfunctionresults.This

appliestoallstringspassedtoandfromyourDLL--eventhosethat

arenestedinrecordsandclasses.ShareMemistheinterfaceunitto

theBORLNDMM.DLLsharedmemorymanager,whichmustbedeployedalong

withyourDLL.ToavoidusingBORLNDMM.DLL,passstringinformation

usingPCharorShortStringparameters.}

uses

SysUtils,Classes;

{$R*.RES}

functionDll_Add(int_1,int_2:

intSum:

=int_1+int_2;

result:

=intSum;

exports

Dll_Add;

作者简介:

马根峰,硕士,研究方向:

数据库应用。

创建了“万能数据库查询分析器”,中文版本《DB查询分析器》、《DBQueryAnalyzer》。

中文版本《DB查询分析器》在国内最大的软件下载网站---中关村在线的数据库下载排行榜中,位于前20位,下载量达到9万次。

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 小学教育 > 语文

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2