ExpandEnvironmentStrings

  DWORD ExpandEnvironmentStrings(lpszSrc, lpszDest, cchDest)    
  LPCTSTR lpszSrc;    
  LPTSTR lpszDest;    
  DWORD cchDest;    

The ExpandEnvironmentStrings function can be used to expand environment variable strings (PATH for example) and replace them with their defined values.

Parameters

lpszSrc

Points to a null-terminated string that might contain references to environment variable strings 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 used by the command interpreter. Case is ignored when looking up the environment variable name and if the name is not found, then the variableName portion is left undisturbed.

lpszDest

Points to a buffer that receives a copy of the source buffer, after all environment variable name substitutions have been performed.

cchDest

Specifies the maximum number of characters that can be stored in the buffer pointed to by lpszDest, including the null terminator.

Return Value

The return value is the number of characters stored in the lpszDest buffer. If the return value is greater than cchDest parameter then it specifies how many characters are needed for the result.