怎么实现把相应的软件信息写到注册表,怎么在软件启动的时候从注册表中读出信息?请高手指点

解决方案 »

  1.   

    Rego:=TRegistry.Create;
          with Rego do
          begin
            try
              RootKey:=HKEY_LOCAL_MACHINE;
              OpenKey('SOFTWARE\Microsoft\WebManage\ftpinfo',True)
              UpdateParam('ftpIp',ftpIp);
              
            finally
              Rego.Free;
            end;
          end;写入注册表
          Rego:=TRegistry.Create;
      with Rego do
      begin
        try
          RootKey:=HKEY_LOCAL_MACHINE;
          OpenKey('SOFTWARE\Microsoft\mssqlserver\client\connectTo',True      WriteString(trim(ftpIp), 'DBMSSOCN,'+trim(ftpIp));
        finally
          Rego.Free;
        end;
       end;
       Showmessage(写入注册表成功');
      

  2.   

    注意 
    在var那儿加上
     Rego:TRegistry;
      

  3.   

    读取uses Registry; 
    function GetRegistryValue: string;
    var
      Registry: TRegistry;
      S: string;
    begin
      Registry:=TRegistry.Create;  Registry.RootKey:=HKEY_LOCAL_MACHINE;
      {False because we do not want to create it if it doesn’t exist}
      Registry.OpenKey('MYKEY',False); 
      Result :=Registry.ReadString('VALUE1');  Registry.Free;
    end;
      

  4.   

    设置开机启动procedure FirstRunSystem(bool : Boolean);
    var
      Reg : TRegistry;
    begin
      Reg := TRegistry.Create;
      Reg.RootKey := HKEY_LOCAL_MACHINE;
      try
        Reg.OpenKey('\Software\Microsoft\Windows\CurrentVersion\Run',False);
        if bool then Reg.WriteString(Application.Title,Application.ExeName)
        else  Reg.DeleteValue(Application.Title);
      finally
        Reg.CloseKey;
        Reg.Free;
      end;
    end;
      

  5.   


    var
     Reg:TRegistry;
    begin
      Reg:=TRegistry.Create;
      try
       Reg.RootKey :=HKEY_CURRENT_USER;
       //打开键,TRUE表示如果键不存在,则创建
       Reg.OpenKey('Software\Myreg',true);
       //在[HKEY_CURRENT_USER\Software\Myreg]下写入DWORD值"abc"=12
       Reg.WriteInteger('abc',12);
      finally
       Reg.CloseKey;
       Reg.Free;
      end; //end of try
    end;
    在Delphi中,可以通过TRegistry类方便地对注册表进行操作。使用TRegistry类的时候,要在uses语句中包含registry单元。
    下面是TRegistry类中定义的几个常用的方法:
     CloseKey 关闭一个键。
     CreateKey 创建一个新键。
     DeleteKey 删除一个已经存在的键
     DeleteValue 删除键中的一个数值
     HasSubKeys 测试一个键是否有子键
     KeyExists 测试一个键是否存在。
     OpenKey 打开一个键。
     ReadBool 读取一个键中某个具体数值,该数值为布尔类型的数据。
     ReadInteger 读取一个键中某个具体数值,该数值为整数类型的数据。
     ReadString 读取一个键中某个具体数值,该数值为字符串类型的数据。
     WriteBool 向一个键中写入某个具体数值,该数值为布尔类型的数据。
     WriteInteger 向一个键中写入某个具体数值,该数值为整数类型的数据
     WriteString 向一个键中写入某个具体数值,该数值为字符串类型的数据。
      

  6.   

    好,谢谢各位`~!其实我是想问怎么从注册表里读出mac地址?有人知道吗?(回答这个问题另外给分)