【发布时间】:2012-06-09 10:56:41
【问题描述】:
我正在Delphi 7 中开发一个应用程序,它将运行并显示由FastMM4.pas 创建的日志。
应用程序将安装在系统的任何位置。我已经修改了FastMM4.pas,这样它就可以CreateProcess(简而言之,执行我的应用程序)
我的previous Question和Sertac Akyuz's answer的代码
leakTracker.exe会以fastmm4的日志文件为参数,打开文件并显示。修改后的fastMM4.pas 将用于任何其他应用程序。
Procedure OpenTheLeakReader
begin
CmdLine := 'C:\Program Files\leakTracker\leakTracker.exe "';
lstrcat(CmdLine,CTheArGuements );
ZeroMemory(@SInfo, SizeOf(SInfo));
SInfo.cb := SizeOf(SInfo);
CreateProcess(nil, CmdLine, nil, nil, False, NORMAL_PRIORITY_CLASS, nil, nil, sInfo, pInfo);
end;
这很好,但我已经硬编码了path,因为要获取我的应用程序路径..
[FastMM4] -cannot use SysUtils.pas //*1
-cannot use Registry.pas //*2
-cannot use ParamStr(0) //*3
-cannot use unitWithSysRegis //*4
[someAplicationWhichWillUseFastMM4] -Uses FastMM4.pas
在FAstMM4.pasfinalization我有这个
if ifLeakedMemory then OpenTheLeakReader;
因为我不能拥有
*1 - SysUtils.pas - 在 FastMM4.pass 中,因为这将卸载 fastmmm4
*2 - Registry.pas - 搜索leakTracker安装路径但会卸载fastmm4
*3 - paramstr(0) - 应用程序结束时出错。
*4 - unitWithSysRegis - 使用 SysUtils,在 Fastm4 使用子句中也无法注册。
所以我被困在如何获取leakTracker.exe的路径并通过CreateProcess将日志文件的路径发送到`leakTracker.exe'。
【问题讨论】:
-
您可以自己导入 Windows registry functions 吗?
-
@Blorgbeard 我不知道该怎么做……有什么例子吗?
-
其实可以用
windows单位吗?它有RegOpenKeyEx、RegGetValueEx等。如果没有,您可以从那里复制定义。 -
@Blorg FastMM 不能使用隐式系统以外的任何单位。
-
@sertac 如果是这样,那是因为 Windows.pas 在其初始化时不进行堆分配
标签: delphi delphi-7 createprocess fastmm