Reg:=TRegistry.Create();
  With Reg Do
  begin
    RootKey:=HKEY_LOCAL_MACHINE;
    If Not OpenKey('Software\Microsoft\Windows\CurrentVersion\RegSoft',True) Then
    begin
      CreateKey('Software\Microsoft\Windows\CurrentVersion\RegSoft');
      OpenKey('Software\Microsoft\Windows\CurrentVersion\RegSoft',True);
    end;
    If ValueExists('RegCode') Then   //RegCode是键值
    begin
      vRegCode:=ReadInteger('RegCode');
      If (vRegCode<>0)And(vRegCode<>100) Then 
      begin
        vRegCode:=vRegCode+5;  
        WriteInteger('RegCode',vRegCode);
      end;
    end
    Else
    WriteInteger('RegCode',5);
为什么老是提示非法的字符,如果把ValueExists去掉,就不会了。
帮忙解释一下好吗?

解决方案 »

  1.   

    怎么会呢?  Reg:=TRegistry.Create();
      With Reg Do
      begin
        RootKey:=HKEY_LOCAL_MACHINE;
        If OpenKey('Software\Microsoft\Windows\CurrentVersion\RegSoft',True) Then
        begin
          If ValueExists('RegCode') Then   //RegCode是键值
          begin
            vRegCode:=ReadInteger('RegCode');
            If (vRegCode<>0)And(vRegCode<>100) Then
            begin
              vRegCode:=vRegCode+5;
              WriteInteger('RegCode',vRegCode);
            end;
          end
          Else
          WriteInteger('RegCode',5);
        end;
      end;