请看下面的程序,帮我看看哪里有问题??不管在注册表的
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run里有没有我加入的chartsoft键。用RegF.KeyExists('chartsoft')返回都是false,我不明白为什么,还请大虾指教。
begin
pathname := application.ExeName ;
RegF := TRegistry.Create;
RegF.RootKey := HKEY_LOCAL_MACHINE;
  if checkbox1.Checked = true then
   begin
     try
       RegF.OpenKey('SOFTWARE\Microsoft\Windows\CurrentVersion\Run',True);
       exist:= RegF.KeyExists('chartsoft');       if exist = false  then
           Regf.WriteString ('chartsoft',pathname);
       except
           application.Destroy ;
       end;
       Regf.CloseKey ;
       RegF.Free ;
   end;
  if checkbox1.checked = false then
   begin
     try
      RegF.OpenKey('SOFTWARE\Microsoft\Windows\CurrentVersion\Run',True);
      exist:= RegF.KeyExists('chartsoft');
       if  exist=true  then
         begin
            delete:= Regf.DeleteKey('chartsoft');
            if delete=true then
                showmessage('已经关闭自动启动')
              else   showmessage('关闭自动启动失败');
          end;
       except
          application.Destroy ;
      end;
       Regf.CloseKey ;
       RegF.Free ;
  end;
end;