internal override void RegisterBrowser() { //Unregister AppId. UnregisterBrowser(); // Register application. var appReg = RootKey.CreateSubKey(string.Format("SOFTWARE\\Clients\\StartMenuInternet\\{0}", AppId)); appReg.SetValue("", AppName); appReg.CreateSubKey("DefaultIcon").SetValue("", AppIcon); appReg.CreateSubKey("shell\\open\\command").SetValue("", AppOpenUrlCommand); // Install info. var appInstallInfo = appReg.CreateSubKey("InstallInfo"); appInstallInfo.SetValue("IconsVisible", 1); appInstallInfo.SetValue("ShowIconsCommand", AppPath); // TOOD: Do I need to support this? appInstallInfo.SetValue("HideIconsCommand", AppPath); // TOOD: Do I need to support this? appInstallInfo.SetValue("ReinstallCommand", AppReinstallCommand); // Register capabilities. var capabilityReg = appReg.CreateSubKey("Capabilities"); capabilityReg.SetValue("ApplicationName", AppName); capabilityReg.SetValue("ApplicationIcon", AppIcon); capabilityReg.SetValue("ApplicationDescription", AppDescription); // Set up protocols we want to handle. var urlAssoc = capabilityReg.CreateSubKey("URLAssociations"); urlAssoc.SetValue("http", AppId); urlAssoc.SetValue("https", AppId); //urlAssoc.SetValue("ftp", AppID); }
/// <summary> /// 지정된 서브키에서 지정된 이름의 값을 읽어온다. /// </summary> /// <param name="subKeyName">레지스트리 키 명</param> /// <param name="name">이름</param> /// <returns>실패시에는 null 값 반환</returns> public object GetValue(string subKeyName, string name) { if (IsDebugEnabled) { log.Debug("레지스트리에서 값을 읽습니다... subKeyName=[{0}], name=[{1}]", subKeyName, name); } object value = null; if (subKeyName.IsNotWhiteSpace()) { using (RegistryKey subKey = RootKey.CreateSubKey(subKeyName)) { if (subKey != null) { value = subKey.GetValue(name); } } } if (IsDebugEnabled) { log.Debug("레지스트리에서 값을 읽었습니다!!! subKeyName=[{0}], name=[{1}], value=[{2}]", subKeyName, name, value); } return(value); }
/// <summary> /// Forcibly creates this subkey /// </summary> public void Create() { if (!Exists()) { if (Root != null) { Root.Writable = true; } RootKey.CreateSubKey(name); Refresh(); } }
internal override void RegisterBrowser() { //Unregister AppId. UnregisterBrowser(); RegistryKey appReg = Registry.CurrentUser.OpenSubKey("SOFTWARE", true); appReg = appReg.CreateSubKey("AdroitTechnologies", RegistryKeyPermissionCheck.ReadWriteSubTree); appReg = appReg.CreateSubKey("BrowserSelector", RegistryKeyPermissionCheck.ReadWriteSubTree); // Register capabilities. var capabilityReg = appReg.CreateSubKey("Capabilities"); capabilityReg.SetValue("ApplicationName", AppName); capabilityReg.SetValue("ApplicationIcon", AppIcon); capabilityReg.SetValue("ApplicationDescription", AppDescription); // Set up protocols we want to handle. var urlAssoc = capabilityReg.CreateSubKey("URLAssociations"); urlAssoc.SetValue("http", AppId); urlAssoc.SetValue("https", AppId); var regApps = RootKey.OpenSubKey(@"SOFTWARE\RegisteredApplications", true); regApps.SetValue(AppId, @"SOFTWARE\AdroitTechnologies\BrowserSelector\Capabilities"); string keyName = @"SOFTWARE\Classes\" + AppId; var classesReg = Registry.CurrentUser.CreateSubKey(keyName); classesReg.SetValue("", AppName); classesReg.CreateSubKey("DefaultIcon").SetValue("", AppIcon); classesReg.CreateSubKey("shell\\open\\command").SetValue("", AppOpenUrlCommand); classesReg = RootKey.CreateSubKey(keyName); classesReg.SetValue("", AppName); classesReg.CreateSubKey("DefaultIcon").SetValue("", AppIcon); classesReg.CreateSubKey("shell\\open\\command").SetValue("", AppOpenUrlCommand); }
public static void Register(Type type) { string ProgID = type.FullName; string Version = type.Assembly.GetName().Version.ToString(); string GUIDstr = "{" + type.GUID.ToString() + "}"; string keyPath = @"Software\Classes\"; RegistryKey regularx86View = RegistryKey.OpenBaseKey(RegistryHive.CurrentUser, RegistryView.Registry32); RegistryKey regularx64View = RegistryKey.OpenBaseKey(RegistryHive.CurrentUser, RegistryView.Registry64); RegistryKey[] keys = { regularx86View.OpenSubKey(keyPath, RegistryKeyPermissionCheck.ReadWriteSubTree, System.Security.AccessControl.RegistryRights.FullControl), regularx64View.OpenSubKey(keyPath, RegistryKeyPermissionCheck.ReadWriteSubTree, System.Security.AccessControl.RegistryRights.FullControl) }; ProgIdAttribute[] attributes = (ProgIdAttribute[])type.GetCustomAttributes(typeof(ProgIdAttribute), false); if (attributes.Length > 0) { ProgID = attributes[0].Value; } foreach (RegistryKey RootKey in keys) { //[HKEY_CURRENT_USER\Software\Classes\Prog.ID] //@="Namespace.Class" RegistryKey keyProgID = RootKey.CreateSubKey(ProgID); keyProgID.SetValue(null, type.FullName); //[HKEY_CURRENT_USER\Software\Classes\Prog.ID\CLSID] //@="{XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}" keyProgID.CreateSubKey(@"CLSID").SetValue(null, GUIDstr); //[HKEY_CURRENT_USER\Software\Classes\CLSID\{XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}] //@="Namespace.Class // //sRegistryKey keyCLSID = RootKey.OpenSubKey(@"CLSID", RegistryKeyPermissionCheck.ReadWriteSubTree, System.Security.AccessControl.RegistryRights.FullControl).CreateSubKey(GUIDstr); RegistryKey keyCLSID = RootKey.OpenSubKey(@"CLSID", true); if (keyCLSID == null) { keyCLSID = RootKey.CreateSubKey("CLSID", RegistryKeyPermissionCheck.ReadWriteSubTree); } keyCLSID = keyCLSID.CreateSubKey(GUIDstr); keyCLSID.SetValue(null, type.FullName); //[HKEY_CURRENT_USER\Software\Classes\CLSID\{XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}\ProgId] //@="Prog.ID" keyCLSID.CreateSubKey("ProgId").SetValue(null, ProgID); //[HKEY_CURRENT_USER\Software\Classes\CLSID\{XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}\InprocServer32] //@="mscoree.dll" //"ThreadingModel"="Both" //"Class"="Namespace.Class" //"Assembly"="AssemblyName, Version=1.0.0.0, Culture=neutral, PublicKeyToken=71c72075855a359a" //"RuntimeVersion"="v4.0.30319" //"CodeBase"="file:///Drive:/Full/Image/Path/file.dll" RegistryKey InprocServer32 = keyCLSID.CreateSubKey("InprocServer32"); SetInprocServer(InprocServer32, type, false); //[HKEY_CURRENT_USER\Software\Classes\CLSID\{XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}\InprocServer32\1.0.0.0] //"Class"="Namespace.Class" //"Assembly"="AssemblyName, Version=1.0.0.0, Culture=neutral, PublicKeyToken=71c72075855a359a" //"RuntimeVersion"="v4.0.30319" //"CodeBase"="file:///Drive:/Full/Image/Path/file.dll" SetInprocServer(InprocServer32.CreateSubKey("Version"), type, true); //[HKEY_CURRENT_USER\Software\Classes\CLSID\{XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}\Implemented Categories\{62C8FE65-4EBB-45E7-B440-6E39B2CDBF29}] keyCLSID.CreateSubKey(@"Implemented Categories\{62C8FE65-4EBB-45E7-B440-6E39B2CDBF29}"); keyCLSID.Close(); } }
public RegistryKey OpenWritable(string path) { string key = SubKey + '\\' + path; return(RootKey.CreateSubKey(key)); }