Is it possible to open regedit and navigate to straight to a specific key using process.start?

有些话、适合烂在心里 提交于 2019-12-11 01:34:34

问题


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.

Thanks in advance!

Edit:

@Arran

-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.

Edit:

@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.


回答1:


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

  1. Set LastKey to your path you want regedit to open in
  2. Launch regedit.

Example:

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);
    }


来源:https://stackoverflow.com/questions/17453384/is-it-possible-to-open-regedit-and-navigate-to-straight-to-a-specific-key-using

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!