新聞中心
這里有您想知道的互聯(lián)網(wǎng)營(yíng)銷解決方案
C#操作注冊(cè)表實(shí)例實(shí)踐淺析
C#操作注冊(cè)表實(shí)例實(shí)踐需要注意什么呢?那開始我們的講解吧:在下面的例子里,要注意:

建項(xiàng)函數(shù):CreateSubKey()
建子鍵函數(shù):SetValue();
- class Program
- //C#操作注冊(cè)表實(shí)例實(shí)踐
- {
- static string Generateguid()//建立GUID值的函數(shù)
- {
- return System.Guid.NewGuid().ToString();
- }
- static void Main(string[] args)
- {
- RegistryKey pregkey;
- string preName;
- //pregkey = Registry.CurrentUser.OpenSubKey(
- "Control Panel\\Desktop\\WindowMetrics",true);
- pregkey = Registry.LocalMachine.OpenSubKey(
- "SOFTWARE\\Microsoft\\Internet Explorer\\Extensions",true);
- //以只讀方式檢索子項(xiàng)
- if (pregkey == null)
- {
- Console.WriteLine("該鍵值不存在");
- } //C#操作注冊(cè)表實(shí)例實(shí)踐
- else
- {
- preName = Generateguid();
- Console.WriteLine(preName);
- Console.WriteLine("找到該鍵值");
- preName = "{" + preName + "}";
- //pregkey.SetValue("MinAnimate","1");
- pregkey.CreateSubKey(preName);
- //建立子項(xiàng)
- pregkey = Registry.LocalMachine.OpenSubKey(
- "SOFTWARE\\Microsoft\\Internet Explorer\\Extensions\\"+preName,
- true);
- //pregkey.SetValue("bbbbb", "0");
- //建立子鍵,如果有此子鍵,則設(shè)值。
- pregkey.SetValue("ButtonText", "添加");
- //鼠標(biāo)放到bar上時(shí)顯示的文字
- pregkey.SetValue("CLSID",
- "{1FBA04EE-3024-11d2-8F1F-0000F87ABD16}");
- //CLSID固定
- pregkey.SetValue("Default Visible", "yes");
- //默認(rèn)可看見 ,C#操作注冊(cè)表實(shí)例實(shí)踐
- pregkey.SetValue("Exec", "D:/IEbar/IEpinout.exe");
- //關(guān)聯(lián)的exe文件
- pregkey.SetValue("HotIcon", "D:/IEbar/Icon2.ico");
- //鼠標(biāo)放到bar上時(shí)顯示的圖樣
- pregkey.SetValue("Icon", "D:/IEbar/Icon1.ico");
- //鼠標(biāo)未放在bar上時(shí)顯示的圖樣
- //pregkey.SetValue("MenuStatusBar", "楊");
- //pregkey.SetValue("MenuText", "我是楊!");
- } //C#操作注冊(cè)表實(shí)例實(shí)踐
- pregkey.Close();
- }
- }
此例子在vs2005,xp系統(tǒng)下調(diào)試通過(guò)。
生成exe文件,直接運(yùn)行,然后打開ie查看工具欄上的效果。
注意:必需要有"D:/IEbar/Icon2.ico"和"D:/IEbar/Icon1.ico"這兩個(gè)文件,否則在ie上看不出效果。
C#操作注冊(cè)表實(shí)例實(shí)踐的基本內(nèi)容就向你介紹到這里,希望對(duì)你了解和學(xué)習(xí)C#操作注冊(cè)表有所幫助。
網(wǎng)站欄目:C#操作注冊(cè)表實(shí)例實(shí)踐淺析
文章鏈接:http://www.5511xx.com/article/cdighjd.html


咨詢
建站咨詢
