Ric*_*enn 13 c# windows registry shell
我正在研究一个将"嵌入"Windows 7系统的项目,这将通过禁用任务管理器并将Windows shell更改为应用程序以及其他内容来实现.
我在这里要做的是以编程方式更改应用程序和explorer.exe之间的Windows shell,我想知道是否有任何方法可以在C#中执行此操作.
目前我有几行代码尝试更改Windows Shell的注册表项,但刷新注册表编辑器后似乎没有任何内容,代码如下所示:
regKey = Registry.LocalMachine.OpenSubKey("SOFTWARE", true).OpenSubKey("Microsoft", true).OpenSubKey("Windows NT", true).OpenSubKey("CurrentVersion", true).OpenSubKey("Winlogon", true);
regKey.DeleteValue("Shell");
regKey.SetValue("Shell", shell);
regKey.Close();
Run Code Online (Sandbox Code Playgroud)
我已经尝试重新启动Windows以查看是否允许shell更改完成,但无济于事.
如果有人能告诉我是否有可能以编程方式进行,以及我在哪里出错,我将不胜感激.
此外,我很高兴知道是否有一种方法来编写程序,以便它始终以管理员权限运行,以便注册表编辑工作.
非常感谢,
理查德
Ric*_*enn 13
在网上搜索了其他位置之后,我终于让Shell更改为正在构建的应用程序的可执行文件.
"嵌入"过程是一个三步过程,对于我正在处理的软件,我们首先禁用任务管理器,然后在本地计算机注册表中设置shell可执行文件,然后在当前用户中重复该过程注册表中.
以下是实现此目的的代码:
public void embedSoftware()
{
try
{
// Disable Task Manager
regKey = Registry.CurrentUser.OpenSubKey(subKey, true).CreateSubKey("System");
regKey.SetValue("DisableTaskMgr", 1);
regKey.Close();
// Change the Local Machine shell executable
regKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", true);
regKey.SetValue("Shell", shell, RegistryValueKind.String);
regKey.Close();
// Create the Shell executable Registry entry for Current User
regKey = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows NT\CurrentVersion\Winlogon", true);
regKey.SetValue("Shell", shell);
regKey.Close();
MessageBox.Show("Embedding Complete");
}
catch (Exception e)
{
MessageBox.Show(e.Message);
}
}
Run Code Online (Sandbox Code Playgroud)
在此示例中,变量"shell"是一个字符串,其中包含要用作新Windows Shell的可执行文件的路径.
除此之外还有一种"解嵌"软件的方法,这种方法只是从当前用户注册表中删除"DisableTaskMgr"和"Shell"值,它还将Local Machine注册表中的"Shell"值重置为"explorer" .可执行程序".
我希望这可以帮助那些以编程方式更改Windows Shell的人.
问候,
理查德
| 归档时间: |
|
| 查看次数: |
3507 次 |
| 最近记录: |