Bo wrote:
I am using RegistryKey.Get Value() method to retrieve values from
Windows Registry. I don't know how to read type REG_MULTI_SZ into a
string array. I have tried
string[] array = (string[]) RKey.GetValue(n ame);
But it gave me "Invalid Cast Exception".
Something else is wrong - it works fine for me. I suspect that the value
being read by RKey.GetValue(n ame) is not really REG_MULTI_SZ.
I'll even post a complete example:
using System;
using Microsoft.Win32 ;
namespace MultiSZTest
{
class Class1
{
[STAThread]
static void Main(string[] args)
{
string [] vals = (string [])
Registry.Curren tUser.GetValue( "test");
}
}
}
Note that I created a REG_MULTI_SZ registry value named "test" under
HKCU using RegEdit. Note that my test worked even if the value had no
data in it or just one string.
I also got no exception if the value "test" did not exist at all. In
that case, the vals array was null.
I did get the InvalidCastExce ption (as expected) if "test" had a type of
REG_SZ.
Now you get to post a complete example that fails.
--
mikeb