(C#)如何在此位置添加注册表项Software\Microsoft \ Windows \ CurrentVersion \ Uninstall [英] (C#) How to add a registry key in this location Software\Microsoft\Windows\CurrentVersion\Uninstall
问题描述
大家好日子!
我只是想问一下,你如何在这个位置创建一个注册表项
Software \ Mysoftoft \ Windows \ CurrentVersion \\ \\ uninstall
我尝试了下面的代码(我偷了这个地方:(,信用卡曾经编码过它),显然在软件密钥中添加了一个子密钥
RegistryKey key = Registry.LocalMachine.OpenSubKey( Software, true );
key.CreateSubKey( AppName);
key = key.OpenSubKey( AppName, true );
key.CreateSubKey( AppVersion);
key = key.OpenSubKey( < span class =code-string> AppVersion, true );
key.SetValue( yourkey, yourvalue);
所以,我尝试通过更改
RegistryKey key = Registry.LocalMachine.OpenSubKey( 软件, true );
到
RegistryKey key = Registry.LocalMachine.OpenSubKey( @ SOFTWARE \ Mycoftoft \ Windows \ CurrentVersion \ Uninstall);
现在它给了我一个例外,即
$ b mscorlib.dll中发生$ b'System.UnauthorizedAccessException'
感谢大家的帮助!
< blockquote> 中的条目Software \ Microoft \ Windows \ CurrentVersi on\Uninstall
通常由Windows Installer创建。因此,为您的程序创建一个intsaller,并且不要试图从您的应用程序正确写入!
Good day everyone!
I just want to ask, how do you create a registry key in this location
Software\Microsoft\Windows\CurrentVersion\Uninstall
I tried the code below (I stole this somewhere :( , credit who ever coded it) and it is obviously adding a subkey in Software Key
RegistryKey key = Registry.LocalMachine.OpenSubKey("Software",true);
key.CreateSubKey("AppName");
key = key.OpenSubKey("AppName", true);
key.CreateSubKey("AppVersion");
key = key.OpenSubKey("AppVersion", true);
key.SetValue("yourkey", "yourvalue");
So, I tried it by changing the
RegistryKey key = Registry.LocalMachine.OpenSubKey("Software",true);
to
RegistryKey key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall");
and it is now giving me an exception which is
'System.UnauthorizedAccessException' occurred in mscorlib.dll
Thank you for the help everyone!
Entries in Software\Microsoft\Windows\CurrentVersion\Uninstall
are typically created by Windows Installer. Hence create an intsaller for your program, and do not try to write there from your application proper!
这篇关于(C#)如何在此位置添加注册表项Software\Microsoft \ Windows \ CurrentVersion \ Uninstall的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!