注册表中的数据名称和数据数值
用什么东西,给个例子

解决方案 »

  1.   

    The following example retrieves a value from a registry entry.#include <Registry.hpp>AnsiString GetRegistryValue(AnsiString KeyName)
    {
      AnsiString S;
      TRegistry *Registry = new TRegistry;
      try
      {
        Registry->RootKey = HKEY_LOCAL_MACHINE;
        // false because we do not want to create it if it doesn’t exist
        Registry->OpenKey(KeyName, false); 
        S = Registry->ReadString("VALUE1");
      }
      __finally
      {
        delete Registry;
      }
      return S;}
      

  2.   

    unction GetRegistryValue(KeyName: string): string;
    var
      Registry: TRegistry;
    begin
      Registry := TRegistry.Create(KEY_READ);
      try
        Registry.RootKey = HKEY_LOCAL_MACHINE;
        // False because we do not want to create it if it doesn't exist
        Registry.OpenKey(KeyName, False); 
        Result := Registry.ReadString('VALUE1');
      finally
        Registry.Free;
      end;
    end;
      

  3.   

    This OnClick event handler adds the value specified in the ValueforKey edit box to the registry key specified by the NameofKey edit box. If the named key does not already exist, it creates one. (Note that if you don抰 want to give the user a choice, this could be accomplished more simply by setting the CanCreate parameter of the OpenKey call to true).procedure TForm1.Button1Click(Sender: TObject);
    var
      Reg: TRegIniFile;
    begin
      if Length(NameofKey.Text) or Length(ValueforKey.Text) <=0 then
        Showmessage('Either the key name or value is missing.')
      else begin
        Reg:=TRegIniFile.Create('MyApp');
        try
          Reg.RootKey:=HKey_Local_Machine; // Section to look for within the registry
          if not Reg.OpenKey(NameofKey.Text,False) then
            if MessageDlg('The specified key does not exist, create it?'                 ,Mtinformation,[mbYes,mbNo],0)=mryes then
            begin
              Reg.CreateKey(NameofKey.Text);
              if not Reg.OpenKey(NameofKey.Text,False) then
                ShowMessage('Error in Opening Created Key')
              else
                Reg.WriteString('Main Section','Value1',ValueForKey.Text);
            end
         else
           Reg.WriteString('Main Section','Value1',ValueForKey.Text);
        finally      Reg.Free;
        end;
      end;
    end;
      

  4.   

    to:huojiehai(海天子) 
    你帮我看看老外的 这个软件要怎么做(关于注册表)
    http://www.bwkj.net/bios/down3/regc.exe
      

  5.   

    下面程序是读出windows中所有的已安装的程序.你自己看一下,很容易的.
    uses Registry;procedure TForm1.Button1Click(Sender: TObject);
    Var  list,softList :TStringList;
         Reg :TRegistry;
         FPath,FKey,SubString:String;
         i: integer;
    begin
       FPath := 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall';
       FKey := 'DisplayName';
       list := TStringList.Create;
       softList := TStringList.Create;
       Reg := TRegistry.Create;
     try
       Reg.RootKey := HKEY_LOCAL_MACHINE;
       If Reg.OpenKey(FPath, False) then
         Reg.GetKeyNames(List);
         List.Sort;
         List.BeginUpdate;
       Reg.CloseKey;
       If Reg.OpenKey(FPath, False) then
          Edit1.Text := List[0];
         //Edit1.Text := Reg.ReadString('DriverDesc');
       Reg.CloseKey;
       for i:=0 to List.Count-1 do begin
          FPath := 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\'+List[i];
          if (Reg.OpenKey(FPath,False)) and (Reg.ReadString(FKey)<>'')  then
            softList.Add(Reg.ReadString(FKey));
          Reg.CloseKey;
       end;//end for
     finally
       Reg.Free; // 用 Try..Finally 结构确保 REG 变量能够释放。
     end;
     softList.Sort;
     ListBox1.Items:=softlist;
    end;