473,396 Members | 1,797 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Accessing %systemroot% value in code

I can execute the following code, and it correctly decodes the system folder
string.
FileVersionInfo versionInfo =
FileVersionInfo.GetVersionInfo("%systemroot%\\syst em32\\xyz.dll");

But what I want to do is determine what the value is, so I can use it in my
own string, such as this:
String fileString = "%systemroot%\\system32\\xyz.dll";

Anyone know how to get the value of that filled in there? thx
Jul 16 '07 #1
8 10406
determining what the value is? which value do you want to know?

Jul 16 '07 #2

"Hakan Fatih YILDIRIM" <hf*********@gmail.comwrote in message
news:11*********************@w3g2000hsg.googlegrou ps.com...
determining what the value is? which value do you want to know?
The value of systemroot, of course.
Jul 16 '07 #3
I believe that you want to call the PathUnExpandEnvStrings API function
through the P/Invoke layer. This is located in shlwapi.dll.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"jeffc" <no****@nospam.comwrote in message
news:O1**************@TK2MSFTNGP02.phx.gbl...
>
"Hakan Fatih YILDIRIM" <hf*********@gmail.comwrote in message
news:11*********************@w3g2000hsg.googlegrou ps.com...
>determining what the value is? which value do you want to know?

The value of systemroot, of course.

Jul 16 '07 #4

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.comwrote in
message news:Om**************@TK2MSFTNGP04.phx.gbl...
I believe that you want to call the PathUnExpandEnvStrings API function
through the P/Invoke layer. This is located in shlwapi.dll.
While not %systemroot% exactly, but I was able to find
System.Environment.SystemDirectory. This might be "C:\Windows\system32",
for example.
Jul 16 '07 #5
Jeff,

The call to the SystemDirectory property will make a call to the
GetSystemDirectory API function underneath the covers. This is fine if you
just want to get the system directory and nothing else. If you want to
translate strings that have the values in it for the systemroot and other
directories, it's better to call the function I mentioned before and have
the OS do it for you.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"jeffc" <no****@nospam.comwrote in message
news:OK****************@TK2MSFTNGP04.phx.gbl...
>
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.comwrote
in message news:Om**************@TK2MSFTNGP04.phx.gbl...
> I believe that you want to call the PathUnExpandEnvStrings API
function through the P/Invoke layer. This is located in shlwapi.dll.

While not %systemroot% exactly, but I was able to find
System.Environment.SystemDirectory. This might be "C:\Windows\system32",
for example.

Jul 16 '07 #6

"jeffc" <no****@nospam.comwrote in message
news:eL**************@TK2MSFTNGP02.phx.gbl...
>I can execute the following code, and it correctly decodes the system
folder string.
FileVersionInfo versionInfo =
FileVersionInfo.GetVersionInfo("%systemroot%\\syst em32\\xyz.dll");

But what I want to do is determine what the value is, so I can use it in
my own string, such as this:
String fileString = "%systemroot%\\system32\\xyz.dll";

Anyone know how to get the value of that filled in there? thx
In native code, ExpandEnvironmentStrings in kernel32.dll

In .NET, System.Environment.ExpandEnvironmentVariables
Jul 16 '07 #7
you can use
System.Environment.SystemDirectory

"jeffc" wrote:
I can execute the following code, and it correctly decodes the system folder
string.
FileVersionInfo versionInfo =
FileVersionInfo.GetVersionInfo("%systemroot%\\syst em32\\xyz.dll");

But what I want to do is determine what the value is, so I can use it in my
own string, such as this:
String fileString = "%systemroot%\\system32\\xyz.dll";

Anyone know how to get the value of that filled in there? thx
Jul 17 '07 #8

"jeffc" <no****@nospam.comwrote in message
news:eL**************@TK2MSFTNGP02.phx.gbl...
>I can execute the following code, and it correctly decodes the system
folder string.
FileVersionInfo versionInfo =
FileVersionInfo.GetVersionInfo("%systemroot%\\syst em32\\xyz.dll");

But what I want to do is determine what the value is, so I can use it in
my own string, such as this:
String fileString = "%systemroot%\\system32\\xyz.dll";

Anyone know how to get the value of that filled in there? thx
>>In .NET, System.Environment.ExpandEnvironmentVariables
This was actually the right answer to my question.
>>System.Environment.SystemDirectory
As it turns out, this was value that I actually wanted! Thanks all.
Jul 17 '07 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Protoculture | last post by:
Using c# I'm trying to access a value from a dataset using the following code. keyword.Text = myDataSet.Tables.Columns.ToString(); but rather than getting the value at that location I just get...
6
by: evandelagrammaticas | last post by:
Hi all. I have spent the better part of a day scouring the newsgroups and I am sure that I must have come across the solution a number of times - but I am still a real newbie at asp.net so please...
5
by: stellstarin | last post by:
I have a html where fields are created and added dynamically on the client side. I use the AppendChild() call to create fields dynamically. On submit i try to get the value for all the...
11
by: Ryan Krauss | last post by:
I have a set of Python classes that represent elements in a structural model for vibration modeling (sort of like FEA). Some of the parameters of the model are initially unknown and I do some...
2
by: timonjue | last post by:
I want to acess a string value from one of my asp pages and write it in all other pages. am new in asp leave alone asp.net how would i do that in asp help
3
by: judy.j.miller | last post by:
Does anyone know why i can't access a form element value using dot notation in firefox, when i'm in a function. Works ok in the body. I'm trying to do this: var FarTemp = faren.temp.value; I...
1
by: runway27 | last post by:
i need help with accessing the value of a variable from a different page. i have an index.php file which has 2 files included to display header and footer and the center portion changes based on...
9
by: Michael | last post by:
Hello! I have a problem accessing the value of selected option. It works fine if i put fixed name of select box, but not if the name is variable. Can anyone help me with it? function...
1
by: vikassawant | last post by:
hi all, Please help me. I declare combo box in one file named as test.java i.e. cmb1 and I want to access value of that combobox in another file. In...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.