delphi 遍历注册表  
官方Delphi 学习QQ群: 682628230(三千人)\n
频道

delphi 遍历注册表


下面程序是读出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;



推荐分享
图文皆来源于网络,内容仅做公益性分享,版权归原作者所有,如有侵权请告知删除!
 

Copyright © 2014 DelphiW.com 开发 源码 文档 技巧 All Rights Reserved
晋ICP备14006235号-8 晋公网安备 14108102000087号

执行时间: 0.049193859100342 seconds