[译]NtRegEdit-本机注册表编辑器
By robot-v1.0
本文链接 https://www.kyfws.com/applications/ntregedit-native-registry-editor-zh/
版权声明 本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
- 12 分钟阅读 - 5994 个词 阅读量 0[译]NtRegEdit-本机注册表编辑器
原文地址:https://www.codeproject.com/Articles/15488/NtRegEdit-Native-Registry-Editor
原文作者:Dan Madden
译文由本站 robot-v1.0 翻译
前言
A replacement for the Registry Editor by Microsoft.
由Microsoft替代注册表编辑器.
- 下载源-254 Kb(Download source - 254 Kb)
- 下载项目(VC ++ 6.0)-7.35 Kb(Download project (VC++ 6.0) - 7.35 Kb) (也下载源)((download source also))
- 下载项目(VC ++ 7.1)-5.8 Kb(Download project (VC++ 7.1) - 5.8 Kb) (也下载源)((download source also))
- 下载项目/帮助(VC ++ 8.0)-60.8 Kb(Download project/Help (VC++ 8.0) - 60.8 Kb) (也下载源)((download source also))
- 下载所有演示(VC ++ 6,7.1,8)-394 Kb(Download all demos (VC++ 6, 7.1, 8) - 394 Kb)
- 下载所有项目/源代码-324 Kb(Download all projects/source - 324 Kb)
介绍(Introduction)
是通过(It is by)没有完成或100%(no means finished or 100%).当我这么说时,我的意思是说它可能无法完全实现我想要的一切.那是因为我很难找到时间使它达到100%.(. When I say that, I mean that it may not perform everything I want 100%. That is because I am finding it hard to find time getting it to 100%.)如果那里有人想要帮助我达到100%,请告诉我!(If there is someone out there that wants to help me get it to 100%, please let me know!!)
我想创建一个使用"本地(I wanted to create a registry editor that used the “Native)**登记处(Registry)**API”,而不是在其中使用Microsoft Registry API(APIs" instead of using the Microsoft Registry APIs in)AdvApi32.dll(AdvApi32.dll)(这只是本机注册表API的包装).仍然依赖((which is just a wrapper to the Native Registry APIs). There is still dependency to the)*AdvApi32.dll(AdvApi32.dll)*因为其中包含所有其他API.我基本上写了一个做到这一点的类(我想它也是一个包装器-见下图).我想创建一些具有与Microsoft注册表编辑器相同功能但又可以做更多事情的功能.我喜欢使用SDI框架,因此决定从此开始.我还想使读取注册表数据更容易一些,所以我决定使用颜色编码.这将使用户更容易根据自己的喜好对信息进行着色,使其更易于阅读且更加用户友好.(because of the all the other APIs in it. I basically wrote a class that does this (I guess it is also a wrapper - see picture below). I wanted to create something that would have the same functionality as Microsoft’s Registry Editor but with the ability to do a lot more. I liked working with the SDI Framework, and decided to start with that. I also wanted to make it a bit easier to read the registry data, so I decided on color coding. This would make it easier for a user to color the information to their liking, making it easier to read and more user-friendly.)
所有注册表查看/修改都严格通过使用(All registry viewing/modification is done strictly by using the) CNtRegistry
我写的类,可以在CodeProject上找到.那里有很多免费和共享软件的注册表编辑器,但是它们不使用本机注册表API来执行其查看/修改.我的目标是创建一个注册表编辑器,该注册表编辑器可以"完全"完成Microsoft RegEdit的工作(class I wrote, which can be found here on CodeProject. There are a lot of Registry editors out there, both free and shareware, but they don’t use Native Registry APIs to perform their viewing/modifications. My goal is to create a registry editor that can do “exactly” what Microsoft’s RegEdit can do)和更多(and more).(.)
使用软件(Using the Software)
您已经通过界面获得了很多有关其功能的信息(因为您知道如何使用Microsoft的RegEdit).我试图将所有真正复杂的内容隐藏在该类中,以使简单性得到体现.这种简单性是在(There’s really a lot you already know about its functionality (because you know how to use Microsoft’s RegEdit) that is available through the interface. I have attempted to hide all the really complicated stuff in the class so that the simplicity comes out. This simplicity was accomplished in the) CRegistry
罗伯特`皮滕格(Robert Pittenger)所在的班级发现(class by Robert Pittenger found) 这里(here) 在CodeProject上,并且是此类总体结构的来源.谢谢罗伯特!(at CodeProject, and is where the overall structure of this class comes from. Thanks Robert!)
使用代码(CNtRegistry)(Using the Code (CNtRegistry))
现在(Now, the) CNtRegistry
我的另一篇文章解释了课堂(class is explained in another article from me) 这里(here) ,所以我建议您去那里获取完整的故事,但是我仅列出其中的一些功能:(, so I would suggest you go there to get the full story, but I will list just a few of the functions in it:)
BOOL SetRootKey(HKEY hKey);
BOOL SetKey(HKEY hRoot, CString csKey, BOOL bCanCreate, BOOL bCanSaveCurrentKey);
BOOL SetKey(CString csKey, BOOL bCanCreate, BOOL bCanSaveCurrentKey);
BOOL CreateKey(CString csKey);
BOOL CreateHiddenKey(CString csKey);
BOOL RenameKey(CString csFullKey, CString csNewKeyName);
BOOL DeleteKey(CString csKey);
BOOL DeleteKeysRecursive(CString csKey);
BOOL FindHiddenKeys(CString csKey, BOOL bRecursive, CStringArray& csaResults);
BOOL Search(CString csString, CString csStartKey, CStringArray& csaResults,
int nRegSearchType = 3, BOOL bCaseSensitive = TRUE);
BOOL CopyKeys(CString csSource, CString csTarget);
如您所见,以上功能非常简单且易于使用.还有更多内容,您应该去阅读这篇文章以获取更多详细信息.(As you can see, the functions above are pretty simple and user-friendly. There is a lot more to it, and you should go look at the article to get more detailed info.)
一些视觉功能(Some Visual Capabilities)
您可以导入/导出本机注册表((You can import/export Native Registry ().neg(.neg*)*)和/或Microsoft注册表(.reg)文件(如果它们是Win2000或更高版本(基本上,如果注册表文件的第一行是"(*) and/or Microsoft Registry (.reg) files if they are Win2000 or greater (basically, if the registry file’s first line is “*)**Windows注册表编辑器版本5.00(*Windows Registry Editor Version 5.00*)**").下图显示了导出文件的两个示例(请注意,它是上图所示的密钥).如果您查看”(*"). The images below show both examples of exported files (notice that it is the Key shown in the picture above). If you look at the “*)*.neg(*.neg*)*“文件,它在密钥” [HKCU \ AppTest \ HiddenKey2(*” file, it has an asterisk (*) after the Key “[HKCU\AppTest\HiddenKey2*)***(***)**]".这样您就可以导入/导出隐藏密钥.(*]”. This is so you can import/export a hidden key.*)
当您尝试导出密钥时,如果要导出的密钥下有密钥,您将看到以下弹出窗口(感谢"(When you attempt to export a Key, you will see the popup below if there are Keys under the one you are trying to export (thanks to “)开窗(Defenestration)").(” for the suggestion).)
这是当前RegEdit格式与NtRegEdit格式相比的映射:(Here is a mapping of the current RegEdit format compared to the NtRegEdit format:)
NtRegEdit(NtRegEdit) | RegEdit(RegEdit) | 注册表类型(Registry Type) |
---|---|---|
@= | @= | (Default) |
=str: | ="" | REG_SZ |
=exp: | =hex(2): | REG_EXPAND_SZ |
=bin: | =hex: | REG_BINARY |
=dw: | =dword: | REG_DWORD |
=dwbe: | =dword: | REG_DWORD_BIG_ENDIAN |
=link: | =hex(6): | REG_LINK |
=multi: | =hex(7): | REG_MULTI_SZ |
=reslist: | =hex(8): | REG_RESOURCE_LIST |
=fullres: | =hex(9): | REG_FULL_RESOURCE_DESCRIPTOR |
=reqlist: | =hex(10): | REG_RESOURCE_REQUIREMENTS_LIST |
=qword: | =hex(b): | REG_QWORD |
密钥创建/修改将弹出如下所示的对话框.它执行许多功能,例如:(Key creations/modifications will bring up the dialog box shown below. It performs a number of functions/capabilities like:)
- 创建普通/隐藏密钥(Creating normal/hidden Keys)
- 复制普通/隐藏密钥(Copying normal/hidden Keys)
- 寻找隐藏的钥匙(Finding hidden Keys)
- 重命名普通/隐藏键(Renaming normal/hidden Keys)
- 搜索键/值/数据(Searching in Keys/values/data)
按下"浏览"按钮,用户可以选择要在其上执行特定任务的键(参见下图):(Pressing the “Browse” button allows a user to select a Key (see picture below) that they want to perform the particular task on:)
现在,我还添加了(Now, I also added an)**应用程序设置(Application Settings)**对话框,可让您设置一些会影响GUI的General/ListCtrl/TreeCtrl.这些对话框中可以进行更多操作(甚至添加更多对话框),但现在就可以了.您可以在下面看到这些对话框:(dialog that allows you to set some General/ListCtrl/TreeCtrl things that affect the GUI. There is a lot more that can go in these dialogs (even adding more dialogs), but for now this is it. You can see these dialogs below:)
-
常规选项卡(General tab)
- 保存窗口位置(Save window position)
- 将窗口保持在最顶层(Keep window top-most)
- 启动时检查操作系统类型(Check OS type on start-up)
- 在启动时检查用户是否是管理员(Check if user is the administrator on start-up)
- 等等…(Etc…)
-
列表控制选项卡(List Control tab)
- 选择一种用于每种注册表类型的颜色(通过单击该项目)(Select a color to use for each Registry type (by clicking on the item))
-
树木控制标签(Tree Control tab)
- 用(Use)**胆大(bold)**用于注册表根键(for registry root Keys)
- 用(Use)**胆大(bold)**用于隐藏的键(for hidden Keys)
- 选择一种用于每个注册表根键的颜色(以及子键-单击该项目)(Select a color to use for each registry root Key (and the subkeys - by clicking on the item))
内部代码(显示键)(The Code Inside (Displaying Keys))
获取注册表信息以构建树状视图的代码也非常简单,仅向您显示当前的Key,并使用(The code to get the registry information to build the tree view is also pretty simple, and only shows you the current Keys, and uses the) GetSubKeyCount()
函数确定键是否具有任何子键.如果是这样,它将添加一个"假项",其整个目的是将键显示为具有子键.每次您在树中向下钻取(通过展开树项目)时,它都会读取注册表中下一级别的Key(请参见下文).这样可以在启动时更快地加载TreeView.(function to determine if the Key has any subkeys. If it does, it adds a “Fake Item”, the whole purpose of which is to show the Key as having subkeys. Every time you drill down in the tree (by expanding a tree item), it reads the registry for the next level of Keys (see below). This allows for a faster loading of the TreeView at start-up.)
// Set the key so we can go through the subkeys
if (m_ntReg.SetKey(csFullKey,FALSE,TRUE)) {
// Holds the subkeys of the current key
CStringArray csaKeys;
if (hItem == NULL) {
hItem = m_hRoot;
}
BOOL bOk = FALSE;
m_ntReg.GetSubKeyList(csaKeys);
for (int n=0; n<csaKeys.GetSize(); n++) {
//
CString csKey(csFullKey);
csKey += _T("\\");
csKey += csaKeys.GetAt(n);
bOk = m_ntReg.SetKey(csKey,FALSE,TRUE);
int nIcon = 5;
if (m_ntReg.m_bHidden) { nIcon = 0; }
HTREEITEM hNewItem =
tc.InsertItem(csaKeys.GetAt(n),nIcon,nIcon,hItem);
SetItemColor(hNewItem,crTextColor);
if (m_ntReg.m_bHidden && theApp.m_clsMainFrm->m_bBoldHidden) {
SetItemBold(hNewItem,TRUE);
}
if (bOk && m_ntReg.GetSubKeyCount() > 0) {
tc.InsertItem(FAKEDITEM,5,5,hNewItem,TVI_LAST);
}
tc.SortChildren(hNewItem);
}
}
现在,我们可以看到子项,当用户单击某个树项时,它会在Key中查询值,并将其显示在列表视图中.用户如何进行列表控件着色设置取决于用户如何查看信息.(Now that we can see the subkeys, when a user clicks on a tree item, it queries the Key for values, and displays them in the list view. How the user has the list control coloring setup depends on how the user sees the information.)
还可以查看给定密钥的权限(只要您具有执行此操作的权限).(There is also the ability to view the permissions of a given Key (as long as you have the permissions to do this).)
列表视图下面还有许多选项卡.这些用于创建/修改注册表数据.由于注册表中只有三种数据格式(二进制,(There is also a number of tabs below the list view. These are for creating/modifying registry data. Since there are only three data formats in the registry (binary,) DWORD
s和strings(3)),这非常简单.无论您在列表视图中单击哪种注册表类型,它都会激活该选项卡并填充数据.到达该位置后,您可以创建一个新值,或直接修改数据.如果在"创建名称"编辑控件中输入任何内容,则将假定您要"创建"新值.如果修改数据,它将假定您要"更新"数据.(s, and strings(3)), this was pretty easy. Whatever registry type you click on in the list view, it will activate that tab and fill the data. Once there, you can create a new value, or simply modify the data. If you enter anything in the “Create Name” edit control, it will assume you want to “Create” a new value. If you modify the data, it will assume you want to “Update” the data.)
还有一个用于查看"搜索和查找隐藏键"结果的标签(由于"(There is also a tab for viewing the “Search and Find Hidden Keys” results (thanks to “)**2005年(Tcpip2005)**如果您从菜单或工具栏中选择"搜索”(和其他命令),则会看到一个带有某些控件的对话框.(" for the suggestion). If you select Search (and other commands) from the menu or toolbar, you will see a dialog box with some controls.)
它并不仅限于此,您还可以在"搜索/查找视图"上"双击",然后您将进入"键",“值名称"和/或"值”.例如,如果您搜索名为" string"的字符串,它将在第1列中显示结果.如果在值名称中找到该单词,则将其放在第2列中.如果在某个值中找到该单词,则将其放在第3列中.当您双击它时,该应用程序将(直观地)向您显示密钥.如果在第2列中有一个值名称,它将突出显示它.如果在第3列中有一个值,它将也突出显示它(基本上,它将向您显示它的位置).即使它是"隐藏密钥",也可以使用.(It doesn’t end just there, you can also “double-click” on the Search/Find View, and you will be taken to the Key, value name, and/or value. For example, if you search for a string named “string”, it will show you the results in column #1. If the word was found in a value name, it will be put in column #2. If the word was found in a value, it will be put it in column #3. When you double-click on it, the app will show you the Key (visually). If there is a value name in column #2, it will highlight it. If there is a value in column #3, it will highlight it too (basically, it will show you where it is). This works even if it is a “hidden Key”.)
结束中…(In Closing…)
这就是我到目前为止所得到的.我不希望这是完美的,所以请给我您的想法以使其变得更好.在生活中要记住的一件事以及随之而来的所有挑战…如果您做出"(That is what I got so far. I don’t expect this to be perfect, so please give me your ideas to make it better. One thing to remember in life itself and all the challenges that come with it … if you make a “)错误(mistake)“并从中学到东西,那么从一开始就永远不是错误的^这是一个”(” and learn from it, then it never was a mistake to begin with…it was a “)课(lesson)”!("!)
谢谢 …(Thanks to …)
NtRegEdit使用在CodeProject上找到的一些非常有用的类/控件:(NtRegEdit uses some very useful classes/controls found here at CodeProject:)
- SDI框架(SDI Framework) 卓兰
M
托多罗维奇(Zoran M.Todorovic)(by Zoran M.Todorovic) - CPPDumpCtrl(CPPDumpCtrl) 尤金`普斯托沃特(Eugene Pustovoyt)(by Eugene Pustovoyt)
- CXListCtrl(CXListCtrl) 汉斯`迪特里希(Hans Dietrich)(by Hans Dietrich)
- CStdioFileEx(CStdioFileEx) 大卫`普里查德(David Pritchard)(by David Pritchard)
- CExtStatusControlBar(CExtStatusControlBar) 德米特里`雅科夫列夫(Dmitriy Yakovlev)(by Dmitriy Yakovlev)
- 应用程序设置对话框(Application Settings Dialog) 由Smaller Animals Software,Inc.(by Smaller Animals Software, Inc.)
- *记忆库(MemDC.h)*通过Keith Rule(by Keith Rule)
- *CoolMenu.cpp/h(CoolMenu.cpp/h)*由Paul DiLascia(MSJ)(by Paul DiLascia (MSJ))
- *子类.cpp/h(Subclass.cpp/h)*保罗`迪拉斯(Paul DiLascia)(by Paul DiLascia)
事情要做(Things To-Do)
- 让它有(Make it have)所有(all)" RegEdit"功能(the “RegEdit” functionality)
- 添加更多RegEdit不具备的本机功能(Add a lot more native functionality that RegEdit doesn’t have)
- 做了(Make it)**真(really)**方便使用的!!(user-friendly!!)
历史(History)
-
2006年9月6日(September 6, 2006)
- 固定的GUI-树/列表视图未正确初始化(Fixed GUI - Tree/List views not initializing correctly)
-
2006年8月23日(August 23, 2006)(0.0.2.857)((0.0.2.857))
- 添加了"安全权限"对话框(Added the Security Permissions dialog)
-
2006年8月10日(August 10, 2006)(0.0.2.734)((0.0.2.734))
-
在"关于"对话框中添加了名称(源所有者)(Added names to the About dialog (source owners))
-
为TreeCtrl添加了粗体选项(Added bold options to the TreeCtrl)
-
添加了"应用程序设置"对话框:(Added Application Settings dialog boxes:)
COptGenDlg()
- 一般(- General)COptListDlg()
-清单控制(- List control)COptTreeDlg()
-树控制(- Tree control)
-
增添了色彩(Added coloring to the)
CNtRegEditTreeView
类((class ()XListCtrl
已经有)(already had it)) -
添加了标签编辑(Added label editing for the)
CTreeCtrl
-
添加了(Added the beginning of the)新(new)" NtRegEdit"格式(“NtRegEdit” format)
-
添加了虚拟密钥:(Added virtual keys:)
VK_UP
(直到下一个"可见"项目(显示值))((Up to the next “visible” item (displays values)))VK_DOWN
(下一个"可见"项(显示值))((Down to next “Visible” item (displays values)))VK_DELETE
(如果存在子项,将提示用户递归)((Will prompt user for recursive if subkey exists))VK_ENTER
(如果存在则打开一个子项,否则无效)((Opens a subkey if it exists, else no effect))
-
修复了(Fixed the)
OnKeysRefresh()
功能(我认为)(function (I think))
-
-
2006年7月16日(July 16, 2006)(0.0.1.689)((0.0.1.689))
- 在状态栏中添加了密钥路径(由于…)(Added Key path in the statusbar (thanks to …))
-
2006年7月10日(July 10, 2006)
- 首次公开发行(Initial public release)
-
2006年7月3日(July 3, 2006)(0.0.0.1)((0.0.0.1))
- 最初的创作(Initial creation)
许可
本文以及所有相关的源代码和文件均已获得The Code Project Open License (CPOL)的许可。
C++ VC8.0 Windows Win2K MFC Visual-Studio Dev 新闻 翻译