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