using RegistryKey to get he value from the registry

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am using
RegistryKey reademai2 = Registry.LocalMachine.OpenSubKey(launch_email_path,
true);
string launch_email = (String)reademai2.GetValue("");
To get the value, in the registry, value = "C:\Program Files\Internet
Explorer\iexplore.exe" -nohome
but If I used string launch_email = (String)reademai2.GetValue("");
I got the value ="\"C:\Program Files\Internet Explorer\iexplore.exe\" -nohome"

System will add "\......\", is it normal?
 
I am using
RegistryKey reademai2 = Registry.LocalMachine.OpenSubKey(launch_email_path,
true);
string launch_email = (String)reademai2.GetValue("");
To get the value, in the registry, value = "C:\Program Files\Internet
Explorer\iexplore.exe" -nohome
but If I used string launch_email = (String)reademai2.GetValue("");
I got the value ="\"C:\Program Files\Internet Explorer\iexplore.exe\" -nohome"

System will add "\......\", is it normal?

Those are just escape characters for the quotes in the string. It is
normal.
 
Is there any way I can remove the escape character automatically or I need to
remove manually, for I will launch the string, if have the escape character,
will cause error.
 
Is there any way I can remove the escape character automatically or I need to
remove manually, for I will launch the string, if have the escape character,
will cause error.

How are you launching the process? The escape characters should not cause
a problem.
 
I used System.Diagnostics.Process.Start(launch_iexplorer); launch_iexplorer
base on the value in registry
 
I used System.Diagnostics.Process.Start(launch_iexplorer); launch_iexplorer
base on the value in registry

Then I suspect it is the -nohome parameter that is causing the problem. If
you remove that does it work? You need to use a ProcessStartInfo object
that allows you to set separately the file to start and the arguments to
pass to the file.
 
My system is XP sp2, I tried
"\"C:\\Program Files\\Internet Explorer\\iexplore.exe\"" from Start->Run,
system show error message, but if run
"C:\\Program Files\\Internet Explorer\\iexplore.exe" system can launch
internet explorer without any program
 
My system is XP sp2, I tried
"\"C:\\Program Files\\Internet Explorer\\iexplore.exe\"" from Start->Run,
system show error message, but if run
"C:\\Program Files\\Internet Explorer\\iexplore.exe" system can launch
internet explorer without any program

From start,run it won't work as that doesn't use the C# language to
interpret the string. But if you are calling Process.Start in a C#
program, which is what I thought you said you were trying to do, the escape
characters will be handled properly.
 
Back
Top