I am trying to get the path of the system root directory by using %SystemRoot% in C code. What I originally had was:
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.Code:TCHAR szBuf[1024]; wsprintf(szBuf, L"c:\\windows\\system32\\myapp.exe \r\n"); WriteLogFile(szBuf);
I know in c++ or in c# you can use the Environment.ExpandEnvironmentVariables Method.
Is there something similar in c that I can use?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"