Lately I have been programming with the windows registry. Alot of
the strings use system environment variables(%systemroot%/etc.)
Ofcourse I could maually parse these things. I was just curious if
there is something I can call(api) wich will automatically parse strings
wich use them? ("%systemroot%\blah.exe")

Any information appreciated as always! :alright:
Posted on 2003-01-08 22:33:57 by natas


DWORD ExpandEnvironmentStrings(
LPCTSTR lpSrc,
LPTSTR lpDst,
DWORD nSize
);

Parameters
lpSrc
[in] Pointer to a null-terminated string that contains 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 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 undisturbed.

lpDst
[out] Pointer to a buffer to receive a copy of the source buffer after all environment-variable name substitutions have been performed.
nSize
[in] Maximum number of TCHARs that can be stored in the buffer pointed to by the lpDst parameter. When using ANSI strings, the buffer size should be the string length, plus terminating null character, plus one. When using Unicode strings, the buffer size should be the string length plus the terminating null character.
Return Values
If the function succeeds, the return value is the number of TCHARs stored in the destination buffer, including the terminating null character. If the destination buffer is too small to hold the expanded string, the return value is the required buffer size, in TCHARs.

If the function fails, the return value is zero. To get extended error information, call GetLastError.
Posted on 2003-01-09 01:19:51 by gfalen
Thanks! Excactly what I needed. :alright:
Posted on 2003-01-09 06:52:32 by natas