本文整理汇总了C#中Microsoft.Win32.RegistryKey.CreateSubKeyChecked方法的典型用法代码示例。如果您正苦于以下问题:C# RegistryKey.CreateSubKeyChecked方法的具体用法?C# RegistryKey.CreateSubKeyChecked怎么用?C# RegistryKey.CreateSubKeyChecked使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Win32.RegistryKey
的用法示例。
在下文中一共展示了RegistryKey.CreateSubKeyChecked方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RegisterVerbCapability
/// <summary>
/// Registers a <see cref="Store.Model.Capabilities.VerbCapability"/> in a registry key.
/// </summary>
/// <param name="registryKey">The registry key to write the new data to.</param>
/// <param name="target">The application being integrated.</param>
/// <param name="capability">The capability to register.</param>
/// <param name="machineWide">Assume <paramref name="registryKey"/> is effective machine-wide instead of just for the current user.</param>
/// <param name="handler">A callback object used when the the user is to be informed about the progress of long-running operations such as downloads.</param>
/// <exception cref="OperationCanceledException">The user canceled the task.</exception>
/// <exception cref="IOException">A problem occurs while writing to the filesystem or registry.</exception>
/// <exception cref="WebException">A problem occured while downloading additional data (such as icons).</exception>
/// <exception cref="UnauthorizedAccessException">Write access to the filesystem or registry is not permitted.</exception>
/// <exception cref="InvalidDataException">The data in <paramref name="capability"/> is invalid.</exception>
internal static void RegisterVerbCapability(RegistryKey registryKey, FeedTarget target, Store.Model.Capabilities.VerbCapability capability, bool machineWide, ITaskHandler handler)
{
#region Sanity checks
if (capability == null) throw new ArgumentNullException("capability");
if (handler == null) throw new ArgumentNullException("handler");
#endregion
if (capability is Store.Model.Capabilities.UrlProtocol) registryKey.SetValue(UrlProtocol.ProtocolIndicator, "");
string description = capability.Descriptions.GetBestLanguage(CultureInfo.CurrentUICulture);
if (description != null) registryKey.SetValue("", description);
// Write verb command information
using (var shellKey = registryKey.CreateSubKeyChecked("shell"))
{
foreach (var verb in capability.Verbs)
{
using (var verbKey = shellKey.CreateSubKeyChecked(verb.Name))
{
string verbDescription = verb.Descriptions.GetBestLanguage(CultureInfo.CurrentUICulture);
if (verbDescription != null) verbKey.SetValue("", verbDescription);
if (verb.Extended) verbKey.SetValue(RegValueExtended, "");
using (var commandKey = verbKey.CreateSubKeyChecked("command"))
commandKey.SetValue("", GetLaunchCommandLine(target, verb, machineWide, handler));
// Prevent conflicts with existing entries
shellKey.DeleteSubKey("ddeexec", throwOnMissingSubKey: false);
}
}
}
// Set specific icon if available, fall back to referencing the icon embedded in the stub EXE
var icon = capability.GetIcon(Icon.MimeTypeIco) ?? target.Feed.GetIcon(Icon.MimeTypeIco);
if (icon != null)
{
using (var iconKey = registryKey.CreateSubKeyChecked(RegSubKeyIcon))
iconKey.SetValue("", IconProvider.GetIconPath(icon, handler, machineWide) + ",0");
}
}