delphi 7,FastMM4无法安装解决方法 [英] delphi 7, FastMM4 cannot install work around
问题描述
我正在使用FastMM4 的应用程序nofollow noreferrer> sourceforge.net 。
因此,我在开始处就在uses子句中添加了 FastMM4.pas
。在应用程序中,我需要在 FinalizeMemoryManager之后运行
batch
文件;在完成后 code>的
个单位FastMM4;
i am working on an application that uses FastMM4
, from sourceforge.net.
So i have added the FastMM4.pas
to the uses clause right at the beginning. In the application i need to run a batch
file after FinalizeMemoryManager;
in the finalization
of unit FastMM4;
like this
initialization
RunInitializationCode;
finalization
{$ifndef PatchBCBTerminate}
FinalizeMemoryManager;
RunTheBatFileAtTheEnd; //my code here..calling a procedure
{$endif}
end.
然后我的 RunTheBatFileAtTheEnd 代码是:
procedure RunTheBatFileAtTheEnd;
begin
//some code here....
sFilePaTh:=SysUtils.ExtractFilePath(applicaTname)+sFileNameNoextension+'_log.nam';
ShellExecute(applcatiOnHAndle,'open', pchar(sExeName),pchar(sFilePaTh), nil, SW_SHOWNORMAL) ;
end;
为此,我需要使用 SysUtils,shellapi
在fastmm4单元的uses子句中。 但是使用
会收到
这条消息
For this i need to use SysUtils,shellapi
in the uses clause of fastmm4 unit. But using them
this message comes
但是,如果我从使用中删除 SysUtils,shellapi
,它将起作用。
我仍然需要安装fastmm4的所有功能,但是使用 SysUtils,shellapi
,没有安装fastmm4
But if i remove SysUtils,shellapi
from the uses it works.
I still need all the features of fastmm4 installed but with SysUtils,shellapi
, fastmm4 is not installed
我有一个自己的单元,但是其完成是在fastmm4结束之前执行的。
I have a unit of my own but its finalization is executed before fastmm4 finalization.
有人可以告诉我如何解决此问题吗?
can anyone tell me can how to fix this problem?
EDIT- 1
unit FastMM4;
//...
...
implementation
uses
{$ifndef Linux}Windows,{$ifdef FullDebugMode}{$ifdef Delphi4or5}ShlObj,{$else}
SHFolder,{$endif}{$endif}{$else}Libc,{$endif}FastMM4Messages,SysUtils,shellapi;
我的应用程序
program memCheckTest;
uses
FastMM4,
EDIT-2:
(在@SertacAkyuz回答之后),我删除了 SysUtils
并起作用了,但是我仍然需要运行批处理文件以通过 RunTheBatFileAtTheEnd
打开外部应用程序。原因是..i我希望外部应用程序仅在FastMM4之后运行,因为 finalization
除外。 sExeName
是将运行文件 sFilePaTh
(。nam)的应用程序。谁能告诉我该怎么做?无需卸载FastMM4
。
(after @SertacAkyuz answer),i removed SysUtils
and it worked , but i still need to run the batch file to open an external application through RunTheBatFileAtTheEnd
. The Reason is ..i want a external application to run only after FastMM4 as been out of the finalization
. The sExeName
is the application that will run the file sFilePaTh
(.nam) . can any one tell how to do this? without uninstalling FastMM4
.
推荐答案
FastMM在调用自行安装默认内存管理器之前,先检查是否设置了默认内存管理器'system.pas'中的IsMemoryManagerSet
函数。如果设置了默认的内存管理器,它将拒绝设置自己的内存管理器,并显示问题中显示的消息。
FastMM checks to see if the default memory manager is set before installing its own by a call to IsMemoryManagerSet
function in 'system.pas'. If the default memory manager is set, it declines setting its own memory manager and displays the message shown in the question.
该消息中有关'fastmm4的指令 .pas应该是项目.dpr文件中的第一个单元,并假设 fastmm4.pas本身没有被修改。
The instruction in that message about 'fastmm4.pas' should be the first unit in the project's .dpr file has the assumption that 'fastmm4.pas' itself is not modified.
fastmm4.pas的uses子句,如果uses子句中包含的任何单元具有初始化
部分,则该部分代码必须在初始化之前运行 fastmm4.pas部分。如果该代码需要通过RTL分配/接收内存,则会设置默认的内存管理器。
When you modify the uses clause of 'fastmm4.pas', if any of the units that's included in the uses clause has an initialization
section, than that section of code have to run before the initialization section of 'fastmm4.pas'. If that code requires allocating/feeing memory via RTL, then the default memory manager is set.
因此,您必须注意将'fastmm4.pas'更改为不包括using子句中的任何此类单位,例如'sysutils.pas'。
Hence you have to take care changing 'fastmm4.pas' to not to include any such unit in the uses clause, like 'sysutils.pas'.
以下示例代码(无错误检查,文件检查等。)显示了如何在不分配任何内存的情况下使用记事本启动FastMM的日志文件(前提是该日志文件存在):
Below sample code (no error checking, file checking etc..) shows how can you launch FastMM's log file with Notepad (provided the log file exists) without allocating any memory:
var
CmdLine: array [0..300] of Char; // increase as needed
Len: Integer;
SInfo: TStartupInfo;
PInfo: TProcessInformation;
initialization
... // fastmm code
finalization
{$ifndef PatchBCBTerminate}
FinalizeMemoryManager; // belongs to fastmm
// Our application is named 'Notepad' and the path is defined in AppPaths
CmdLine := 'Notepad "'; // 9 Chars (note the opening quote)
Len := windows.GetModuleFileName(0, PChar(@CmdLine[9]), 260) + 8;
// assumes the executable has an extension.
while CmdLine[Len] <> '.' do
Dec(Len);
CmdLine[Len] := #0;
lstrcat(CmdLine, '_MemoryManager_EventLog.txt"'#0); // note the closing quote
ZeroMemory(@SInfo, SizeOf(SInfo));
SInfo.cb := SizeOf(SInfo);
CreateProcess(nil, CmdLine, nil, nil, False,
NORMAL_PRIORITY_CLASS, nil, nil, sInfo, pInfo);
{$endif}
end.
这篇关于delphi 7,FastMM4无法安装解决方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!