W
wesley.hs76
Hello,
I've the following two problems. I want to write an inifile to the
Windows directory. And I wanna write variables to the Registry. For
both things I get an UnauthorizedAccessException. This problem started
when I'm using Windows Vista. (Windows XP this problem never happens.)
Can somebody give a solution, how to solve this? This a part of my
source:
static string FBestandnaam;
...
public string Naam
{
...
}
...
public void Reset()
{
if (FFullBestandnaam != null)
Close();
// UnauthorizedAccessException => Here the exception
starts
FFullBestandnaam = File.Open(Naam, FileMode.OpenOrCreate,
FileAccess.ReadWrite);
FFullBestandnaam.Position = 0;
}
private static RegistryKey _Key_LocalMachine =
Registry.LocalMachine;
private static RegistryKey _Key_Software;
private static RegistryKey _Key_Company;
private static RegistryKey _Key;
private static RegistryKey _Subkey;
...
static void InitRegistry()
{
_Key_Software =
_Key_LocalMachine.OpenSubKey(sKEY_SOFTWARE, true);
using (RegistryKey
// UnauthorizedAccessException => Here the exception
starts
tempKey =
_Key_LocalMachine.CreateSubKey(sKEY_SOFTWARE))
{
_Key_Software =
_Key_LocalMachine.OpenSubKey(sKEY_SOFTWARE, true);
}
_Key_Company = _Key_Software.OpenSubKey(sKEY_COMPANY,
true);
using (RegistryKey
tempKey = _Key_Software.CreateSubKey(sKEY_COMPANY))
{
_Key_Company = _Key_Software.OpenSubKey(sKEY_COMPANY,
true);
}
}
Yours sincerly, Wesley
I've the following two problems. I want to write an inifile to the
Windows directory. And I wanna write variables to the Registry. For
both things I get an UnauthorizedAccessException. This problem started
when I'm using Windows Vista. (Windows XP this problem never happens.)
Can somebody give a solution, how to solve this? This a part of my
source:
static string FBestandnaam;
...
public string Naam
{
...
}
...
public void Reset()
{
if (FFullBestandnaam != null)
Close();
// UnauthorizedAccessException => Here the exception
starts
FFullBestandnaam = File.Open(Naam, FileMode.OpenOrCreate,
FileAccess.ReadWrite);
FFullBestandnaam.Position = 0;
}
private static RegistryKey _Key_LocalMachine =
Registry.LocalMachine;
private static RegistryKey _Key_Software;
private static RegistryKey _Key_Company;
private static RegistryKey _Key;
private static RegistryKey _Subkey;
...
static void InitRegistry()
{
_Key_Software =
_Key_LocalMachine.OpenSubKey(sKEY_SOFTWARE, true);
using (RegistryKey
// UnauthorizedAccessException => Here the exception
starts
tempKey =
_Key_LocalMachine.CreateSubKey(sKEY_SOFTWARE))
{
_Key_Software =
_Key_LocalMachine.OpenSubKey(sKEY_SOFTWARE, true);
}
_Key_Company = _Key_Software.OpenSubKey(sKEY_COMPANY,
true);
using (RegistryKey
tempKey = _Key_Software.CreateSubKey(sKEY_COMPANY))
{
_Key_Company = _Key_Software.OpenSubKey(sKEY_COMPANY,
true);
}
}
Yours sincerly, Wesley