I am trying to get the path of the system root directory by using %SystemRoot% in C code. What I originally had was:

Code:
TCHAR szBuf[1024];
wsprintf(szBuf, L"c:\\windows\\system32\\myapp.exe \r\n");
WriteLogFile(szBuf);
Now, I want to grab the system root directory at runtime and use that instead of hardcoding in the location as on win2k, the path is "c:\winnt" or people may have installed their os on a different drive.

I know in c++ or in c# you can use the Environment.ExpandEnvironmentVariables Method.
Code:
String query = "My system drive is %SystemDrive% and my system root is %SystemRoot%";
String  str = Environment.ExpandEnvironmentVariables(query);

This will give an output of something like: "My system drive is C: and my system root is C:\WINNT"
Is there something similar in c that I can use?