是否可以打开 regedit 并使用 process.start 直接导航到特定键? [英] Is it possible to open regedit and navigate to straight to a specific key using process.start?

查看:58
本文介绍了是否可以打开 regedit 并使用 process.start 直接导航到特定键?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在制作一个可以在注册表中写入一个键的小工具,为了方便起见,其中的一小部分是通过单击按钮立即导航到该键.我已经知道如何打开 regedit.exe 但有没有办法立即导航到我需要的密钥?我正在尝试使用

I'm making a small tool that can write a key in registry, and a tiny part of it just for convenience would be to navigate to that key instantly with the click of a button. I know how to open regedit.exe already but is there a way to instantly navigate to the key i need? I'm trying with

System.Diagnostics.Process.Start("regedit.exe" + "c/HKEY_LOCAL_MACHINE");

但我认为这只是试图将一个密钥写入注册表.

but i think it's just trying to write a key into registry.

提前致谢!

@阿兰

-其实这个工具主要是给我自己用的.我仍然是 C# 或编程方面的新手,我正在自己学习.这个程序 1/2 是我能做什么的测试,1/2 是我以后工作的实用程序.我的目标是能够将一个密钥写入注册表,然后能够导航到它并在几秒钟内将其删除,而无需手动搜索 regedit.

-Actually the tool is for myself mainly. I'm still very much a newb at c# or programming in general, and I am learning it on my own. This program is 1/2 a test of what I can do and 1/2 a utility for my later work. My goal with this is to be able to write a key into registry and after that be able to navigate to it and delete it in seconds with out having to manually search through the regedit.

@Hans Passant

@Hans Passant

谢谢你提供的信息!我想如果它很难实施,那真的不值得我花时间和精力.

Thank you for the information! I guess if it's that hard to implement, it's really not worth my time and effort.

推荐答案

如果其他人通过谷歌搜索这个作品,这个帖子有点老了.

This thread is a bit old bit if anyone else ends up here by googling this works.

  1. 将 LastKey 设置为您希望 regedit 打开的路径
  2. 启动注册表编辑器.

示例:

var registryLocation =  "Your key here";
var registryLastKey = @"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Applets\Regedit";           
    try
    {
        Registry.SetValue(registryLastKey, "LastKey", registryLocation); // Set LastKey value that regedit will go directly to
        Process.Start("regedit.exe");
    }
    catch (Exception ex)
    {
        MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
    }

这篇关于是否可以打开 regedit 并使用 process.start 直接导航到特定键?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆