Digg StumbleUpon LinkedIn YouTube Flickr Facebook Twitter RSS Reset

Accès à la base de registre de windows

Modifier,ou,créer,une,source,d'événement
{filelink=15689}

using System;
using Microsoft.Win32;
using System.Security.Permissions;
 
class AccesRegistre
{
  static void Main(string[] args)
  {
    try
    {
      RegistryPermission regPermission = new RegistryPermission(RegistryPermissionAccess.AllAccess,@"HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindows NTCurrentVersion");
      regPermission.Demand();
    } catch (Exception e) {
      Console.WriteLine(e.Message);
      return;
    }
 
    RegistryKey myRegKey=Registry.LocalMachine;
    myRegKey=myRegKey.OpenSubKey (@"SOFTWAREMicrosoftWindowsNTCurrentVersion");
    try
    {
        Object oValue = myRegKey.GetValue("PathName");
      Console.WriteLine("SE Pathname: {0}",oValue.ToString());
    }
    catch (NullReferenceException err)
    {
        Console.WriteLine(err);
    }
  }
}

No comments yet.

Leave a Comment