Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/delphi/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/solr/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Delphi 当使用FastMM4时,如何从代码中检测_Delphi_Delphi 10.3 Rio - Fatal编程技术网

Delphi 当使用FastMM4时,如何从代码中检测

Delphi 当使用FastMM4时,如何从代码中检测,delphi,delphi-10.3-rio,Delphi,Delphi 10.3 Rio,我想在使用FastMM4时在表单上显示一个标签(“在项目文件中使用”),这样我就不会把可执行文件给没有安装FastMM\u FullDebugMode.dll的人 我试过这些,但没有效果: {$ifdef FullDebugMode} LblFastMM4.Visible := true; {$endif} {$ifdef EnableMemoryLeakReporting} LblFastMM4.Visible := true; {$endif} 如何在运行时检测FastMM4 注意:我没

我想在使用FastMM4时在表单上显示一个标签(“在项目文件中使用”),这样我就不会把可执行文件给没有安装
FastMM\u FullDebugMode.dll
的人

我试过这些,但没有效果:

{$ifdef FullDebugMode}
LblFastMM4.Visible := true;
{$endif}

{$ifdef EnableMemoryLeakReporting}
LblFastMM4.Visible := true;
{$endif}
如何在运行时检测FastMM4


注意:我没有使用FastMM4“正式”发布应用程序。当我想把alpha版本给非技术用户快速查看时,这只是对我自己的一个提醒。如果他们随后遇到错误,那就很烦人了。

您的
{$ifdef}
不起作用,因为您自己的代码没有直接包含
FastMM4Options.inc
,所以您的代码范围中没有定义FastMM的条件。它们仅在FastMM的代码范围内定义。您无法测试在其他人的单元中是否存在
{$define}
'd条件

但是,您可以使用检查范围内的公共符号,以避免使用其他单元。在这种情况下,
FastMM4.pas
接口
部分在特定条件下声明各种符号,例如定义
TRegisteredMemoryLeak
时,定义
启用MemoryLeakReporting
时,定义
DebugGetMem
时,等等

{$if声明(DebugGetMem)}
LblFastMM4.Visible:=true;
{$endif}
{$if声明(TRegisteredMemoryLeak)}
LblFastMM4.Visible:=true;
{$endif}
试试这个:
LblFastMM4.Visible:=InitializationCodeHasRun

可以为FastMM配置许多选项。在您的情况下,选项donotinstallfdllmissing可能很有价值。一个很好的应用程序可用于设置选项:

“这样我就不会错误地将可执行文件提供给没有安装FastMM_FullDebugMode.dll的人”-为什么不简单地将dll与应用程序一起部署?安装DLL不是用户的责任。这是你的应用程序,你有责任部署和安装它需要的任何依赖项。再说一次,你为什么不简单地用你给出的每个alpha部署DLL呢?没有那么难。FastMM可以配置很多选项。在您的情况下,选项donotinstallfdllmissing可能很有价值。一个很好的应用程序可用于设置选项:@Erwin我测试了你的建议,效果很好。你能给我一个答案让我投票吗it@Jan多根:好听!经过40年的编程,还有很多东西需要学习:我没有听你在第一段中说的话。但是请注意:这些符号在我的表单中是未知的,除非我在表单中也使用FastMM4。这有点好,我可以禁用两个uses文件而不是一个。一个会更好;-)@詹多根你看过我链接的文档了吗?如果
fastm4
不在表单的
uses
子句中,或者它没有使用您感兴趣的特定条件进行编译,那么
{If}
将简单地评估为false这对我来说很好,因此我将其标记为“正确”答案。如果我现在意外地给某人一个包含FastMM的可执行文件,那么他们不会得到丢失的DLL错误