procedure TSetupForm.FormActivate(Sender: TObject);
begin
  OnActivate:=nil;
  pReg:=nil;
  try
    pReg:=TRegistry.Create();
    pReg.RootKey:=HKEY_LOCAL_MACHINE;
    if pReg.OpenKey(SYSKEY,false)=true then  //SYSKEY:系统键,比如:SYSKEY='\SoftWare\csdn'
    begin
      MaskEdit1.Text:=pReg.ReadString('Font');
      MaskEdit2.Text:=pReg.ReadString('Position');
      MaskEdit3.Text:=pReg.ReadString('User');
      MaskEdit4.Text:=pReg.ReadString('Password');
    end 
  finally
    pReg.CloseKey;
  end;
end;

解决方案 »

  1.   

    uses
      Registry, TypInfo;procedure TForm1.FormCreate(Sender: TObject);
    begin
      with TRegistry.Create do try
        RootKey := HKEY_CURRENT_USER;
        if OpenKey('\Software\MySoft\Font', False) then begin
          Font.Name := ReadString('Name');
          Font.Size := StrToIntDef(ReadString('Size'), 0);
          Font.Color := StringToColor(ReadString('Color'));
          SetSetProp(Font, 'Style', ReadString('Style'));
          CloseKey;
        end;
      finally
        Free;
      end;
    end;procedure TForm1.FormDestroy(Sender: TObject);
    begin
      with TRegistry.Create do try
        RootKey := HKEY_CURRENT_USER;
        if OpenKey('\Software\MySoft\Font', True) then begin
          WriteString('Name', Font.Name);
          WriteString('Size', IntToStr(Font.Size));
          WriteString('Color', ColorToString(Font.Color));
          WriteString('Style', GetSetProp(Font, 'Style'));
          CloseKey;
        end;
      finally
        Free;
      end;
    end;procedure TForm1.Button1Click(Sender: TObject);
    begin
      if FontDialog1.Execute then Font.Assign(FontDialog1.Font);
    end;
      

  2.   

    写到ini文件华中也可以呀,偶不喜欢往注册表里加东西
    :p
      

  3.   

    to : zswang(伴水)(需要充充电) 能否解释一下GetSetProp等等,以及还有其他什么函数?谢了
      

  4.   

    SetSetProp()//设置集合属性
    GetSetProp()//获取集合属性
    SetStrProp()//设置字符属性
    GetStrProp()//获取字符属性
    SetOrdProp()//设置有序属性
    GetOrdProp()//获取有序属性