unit Path_Utils;
// Thomas Wassermann (Bummi)
interface
uses Windows;
Function ExpandEnvironmentStrings_D(
Const s:
String):
String;
Function PathUnExpandEnvStrings_D(
Const s:
String):
String;
{$IFDEF UNICODE}
Function PathUnExpandEnvStrings(pszPath, pszBuf: PChar; cchBuf: UINT): BOOL;
stdcall;
{$ELSE}
Function PathUnExpandEnvStrings(pszPath, pszBuf: PChar; cchBuf: UINT): BOOL;
stdcall;
{$ENDIF}
implementation
{$IFDEF UNICODE}
Function PathUnExpandEnvStrings;
External '
shlwapi.dll'
Name '
PathUnExpandEnvStringsW';
{$ELSE}
Function PathUnExpandEnvStrings;
External '
shlwapi.dll'
Name '
PathUnExpandEnvStringsA';
{$ENDIF}
Function ExpandEnvironmentStrings_D(
Const s:
String):
String;
begin
SetLength(Result,ExpandEnvironmentStrings(PChar(s),Pchar(Result),0));
ExpandEnvironmentStrings(Pchar(s),Pchar(Result),Length(Result));
end;
Function PathUnExpandEnvStrings_D(
Const s:
String):
String;
var
i:Integer;
begin
SetLength(Result,MAX_PATH);
PathUnExpandEnvStrings(PChar(s),Pchar(Result),MAX_PATH);
Result := PChar(Result);
end;
end.