FSF.ExpandEnvironmentStr

Far Manager

ExpandEnvironmentStr

The FSF.ExpandEnvironmentStr function is used to expand environment variables in a string to their values.
DWORD WINAPI ExpandEnvironmentStr(
  const char *Src,
  char *Dest,
  size_t Size
);

Parameters

Src
Pointer to a null-terminated string containing references to environment variables of the form: %VariableName%. For each such reference, the %VariableName% portion is replaced with the current value of that environment variable.

The replacement rules are the same as those used by the command interpreter. Case is ignored when looking up the environment-variable name. If the name is not found, the %VariableName% portion is left unchanged.

Dest
Pointer to the buffer that will receive the result of the expansion. May be the same as Src.
Size
Size of the destination buffer (Dest), including the trailing '\0'.

Return value

The function returns the number of characters stored into the buffer. If the environment variable expansion fails, up to (Size-1) characters are copied from Src to Dest.

Remarks

  1. This function is just a "wrapper" for the ExpandEnvironmentStrings Windows API function, so you can see Windows API documentation for the details.
  2. Unlike ExpandEnvironmentStrings FSF.ExpandEnvironmentStr always fills Dest buffer.
  3. Src and Dest must be in the OEM code page.