Memory issue when using SHGetSpecialFolderLocation (deprecated)
This commit is contained in:
parent
b779a0e6af
commit
c0ca278638
22
X2UtApp.pas
22
X2UtApp.pas
@ -418,16 +418,13 @@ procedure TX2App.GetPath();
|
|||||||
(APath);
|
(APath);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{$IFNDEF DXE2PLUS}
|
||||||
|
procedure GetPaths;
|
||||||
var
|
var
|
||||||
ifMalloc: IMalloc;
|
ifMalloc: IMalloc;
|
||||||
pIDL: PItemIDList;
|
pIDL: PItemIDList;
|
||||||
cPath: array[0..MAX_PATH] of Char;
|
cPath: array[0..MAX_PATH] of Char;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
FFileName := GetModule(SysInit.HInstance);
|
|
||||||
FPath := FixPath(ExtractFilePath(FFileName));
|
|
||||||
FMainPath := FixPath(ExtractFilePath(GetModule(0)));
|
|
||||||
|
|
||||||
SHGetMalloc(ifMalloc);
|
SHGetMalloc(ifMalloc);
|
||||||
try
|
try
|
||||||
FillChar(cPath, SizeOf(cPath), #0);
|
FillChar(cPath, SizeOf(cPath), #0);
|
||||||
@ -436,7 +433,7 @@ begin
|
|||||||
|
|
||||||
FUserPath := FixPath(cPath);
|
FUserPath := FixPath(cPath);
|
||||||
|
|
||||||
|
cPath := '';
|
||||||
FillChar(cPath, SizeOf(cPath), #0);
|
FillChar(cPath, SizeOf(cPath), #0);
|
||||||
SHGetSpecialFolderLocation(0, CSIDL_COMMON_APPDATA, pIDL);
|
SHGetSpecialFolderLocation(0, CSIDL_COMMON_APPDATA, pIDL);
|
||||||
SHGetPathFromIDList(pIDL, @cPath);
|
SHGetPathFromIDList(pIDL, @cPath);
|
||||||
@ -446,6 +443,19 @@ begin
|
|||||||
ifMalloc := nil;
|
ifMalloc := nil;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
|
begin
|
||||||
|
FFileName := GetModule(SysInit.HInstance);
|
||||||
|
FPath := FixPath(ExtractFilePath(FFileName));
|
||||||
|
FMainPath := FixPath(ExtractFilePath(GetModule(0)));
|
||||||
|
{$IFDEF DXE2PLUS}
|
||||||
|
FUserPath := FixPath(System.IOUtils.TPath.GetHomePath);
|
||||||
|
FProgramDataPath := FixPath(System.IOUtils.TPath.GetPublicPath);
|
||||||
|
{$ELSE}
|
||||||
|
GetPaths;
|
||||||
|
{$ENDIF}
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
function TX2App.GetVersion(): TX2AppVersion;
|
function TX2App.GetVersion(): TX2AppVersion;
|
||||||
|
Loading…
Reference in New Issue
Block a user