怎么读注册表的值

来源:互联网 发布:paragon ntfs foe mac 编辑:程序博客网 时间:2024/04/20 12:03
 

读注册表的时候要引用到Registry这个单元 下面的代码是实现把指定数据库按当天日期备份到SQL安装目录下的备份目录下

var

  vRegPath: TRegistry;

  vPath: string;

  vCommand: TADOCommand;

begin

  vCommand := TADOCommand.Create(nil);

  vRegPath := TRegistry.Create;

  try

    vRegPath.RootKey := HKEY_LOCAL_MACHINE;

    vRegPath.OpenKey('Software\Microsoft\MSSQLServer\MSSQLServer', False);

    vPath := vRegPath.ReadString('BackupDirectory');

    vPath := vPath + '\' + DateToStr(Now) + '.BAK';

    vCommand.ConnectionString := DBService.GetConnectionString;

    vCommand.CommandTimeout := 10000;

    vCommand.CommandText := Format(vSQL, ['Test', vRegPath]);

    vCommand.Execute;

  finally

    vRegPath.Free;

    vCommand.Free;

  end;

原创粉丝点击