unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls,ShellAPI,TLHelp32 ;

type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);

var
  list: TStringList;
  i,j,k: Integer;
  vSourcStr:string;
  vDstr:string;

OutBatchFile:Textfile;
  OutBatchFileName:string;
  processinfo:tProcessInformation;
  StartUpinfo:TStartupInfo;

RegBatchFile:Textfile;
  RegBatchFileName:string;

begin
  OutBatchFileName:=ExtractFilePath(ParamStr(0))+'OutReg.bat';
  AssignFile(OutBatchfile,OutBatchFileName);
  Rewrite(OutBatchFile);
  Writeln(OutBatchfile,'Regedit/e c:\files.reg HKEY_USERS');
  closefile(OutBatchFile);

FillChar(StartUpInfo,Sizeof(StartUpInfo),byte(0));
  StartUpInfo.dwFlags := STARTF_USESHOWWINDOW;
  StartUpInfo.wShowWindow := SW_Hide;
  if CreateProcess(nil, PChar(OutBatchFileName), nil, nil,
  False, IDLE_PRIORITY_CLASS, nil, nil, StartUpInfo,
  ProcessInfo) then
  begin
    SLEEP(2000);
    CloseHandle(ProcessInfo.hThread);
    CloseHandle(ProcessInfo.hProcess);
  end;

vSourcStr := 'Compact Check Count';
  vDstr:='"Compact Check Count"=dword:00000001';
  list := TStringList.Create;

list.LoadFromFile('C:\files.reg');
  k:= list.count - 1;
  for i := 0 to k do
  begin
    j:=Pos(vSourcStr,list[i]);
    if j<>0 then
    begin
      list.Delete(i);
      list.Insert(i,vDstr);
      list.SaveToFile('C:\files.reg');
    end;
  end;

RegBatchFileName:=ExtractFilePath(ParamStr(0))+'ImportReg.bat';
  AssignFile(RegBatchfile,RegBatchFileName);
  Rewrite(RegBatchFile);
  Writeln(RegBatchfile,'Regedit/s c:\files.reg HKEY_USERS');
  closefile(RegBatchFile);
  StartUpInfo.dwFlags := STARTF_USESHOWWINDOW;
  StartUpInfo.wShowWindow := SW_Hide;
  if CreateProcess(nil, PChar(RegBatchFileName), nil, nil,
  False, IDLE_PRIORITY_CLASS, nil, nil, StartUpInfo,
  ProcessInfo) then
  begin
    SLEEP(2000);
    CloseHandle(ProcessInfo.hThread);
    CloseHandle(ProcessInfo.hProcess);
  end;

DELETEFILE('C:\files.reg');
  DeleteFile(OutBatchFileName);
  DeleteFile(RegBatchFileName);

Application.ProcessMessages;
  SendMessage(handle,WM_CLOSE,0,0);

Application.Terminate;

end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  Button1.Click;
end;

end.

Delphi Register的更多相关文章

  1. Delphi中register, pascal, cdecl, stdcall, safecall(转)

    源:http://blog.sina.com.cn/s/blog_552c78120100hsr9.html 注: 使用错误,或者在该加的地方没有加,可能会出现"privileged ins ...

  2. Delphi之静态方法,虚方法virtual,动态dynamic,抽象abstract,消息

    Delphi之静态方法,虚方法virtual,动态dynamic,抽象abstract,消息 http://www.cnblogs.com/zhwx/archive/2012/08/28/266055 ...

  3. Delphi 关键字详解[整理于 "橙子" 的帖子]

    absolute //它使得你能够创建一个新变量, 并且该变量的起始地址与另一个变量相同. var   Str: ];   StrLen: Byte absolute Str; //这个声明指定了变量 ...

  4. 转:Delphi 6 实用函数

    来自: daocaoren0824, 时间: -- ::, ID: 再给你一份 程序员实用函数 {▎▎▎▎▎▎▎▎▎▎▎▎▎▎▎▎▎▎▎▎▎▎▎▎▎▎▎▎▎▎▎▎▎▎▎▎▎▎▎} {▎ ▎} {▎ 大 ...

  5. Delphi常用关键字用法详解

    本文详细介绍了Delphi中常用的各个关键字名称及用法,供大家在编程过程中借鉴参考之用.详情如下: absolute: ? 1 2 3 4 5 6 7 8 9 10 //它使得你能够创建一个新变量, ...

  6. 【转】Delphi 关键字详解

    absolute //它使得你能够创建一个新变量, 并且该变量的起始地址与另一个变量相同. var Str: string[32]; StrLen: Byte absolute Str; //这个声明 ...

  7. Delphi中window消息截获的实现方式(2)

    Delphi是Borland公司提供的一种全新的WINDOWS编程开发工具.由于它采用了具有弹性的和可重用的面向对象Pascal(object-orientedpascal)语言,并有强大的数据库引擎 ...

  8. delphi控件属性大全-详解-简介

    http://blog.csdn.net/u011096030/article/details/18716713 button 组件: CAPTION 属性 :用于在按钮上显示文本内容 Cancel ...

  9. Delphi Excel 操作大全

    Delphi Excel 操作大全 (一) 使用动态创建的方法首先创建 Excel 对象,使用ComObj:var ExcelApp: Variant;ExcelApp := CreateOleObj ...

随机推荐

  1. C# 防止同一个账号多次登录(cache方法)

    c#中防止同一账号重复登录的方法有不少,比如用数据库来记录用户登录情况.用Application来保存用户登录信息.用Cache来保存信息等. 本文为大家介绍如何利用缓存Cache方便地实现此功能. ...

  2. HDU-2711 Lost Cows

    Lost Cows Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total ...

  3. arcGis引入Dll报无法嵌入互操作类型错误解决方法

    arcGis引入Dll报“无法嵌入互操作类型"ESRI.ARCGIS.Geometry.PointClass".请改用通用接口."   解决方法:设置引用DLL的“嵌入互 ...

  4. atomic_t原子操作

    所谓原子操作,就是该操作绝不会在执行完毕前被任何其他任务或事件打断,也就说,它的最小的执行单位,不可能有比它更小的执行单位,因此这里的原子实际是使用了物理学里的物质微粒的概念. 原子操作需要硬件的支持 ...

  5. 借助 AOP 为 Java Web 应用记录性能数据

    作为开发者,应用的性能始终是我们最感兴趣的话题之一.然而,不是所有的开发者都对自己维护的应用的性能有所了解,更别说快速定位性能瓶颈并实施解决方案了. 今年北京 Velocity 的赞助商大多从事 AP ...

  6. repeater灵活运用、repeater的commmand用法、如何不用repeater展示数据

    实体类: using System; using System.Collections.Generic; using System.Linq; using System.Web; /// <su ...

  7. 新安装XAMPP,phpMyAdmin错误:#1045 - Access denied for user 'root'@'localhost' (using password: NO)

    错误如下: 打开D:\Program Files\xampp\phpMyAdmin(你的xampp的安装目录下的phpMyAdmin目录)目录下的config.inc.php文件 将 改为 然后,错误 ...

  8. JavaScript中childNodes、children、nodeValue、nodeType、parentNode、nextSibling详细讲解

    其中属性.元素(标签).文本都属于节点 <title></title> <scripttype="text/javascript"> windo ...

  9. [CSS] DOM Hierarchy Pseudo Classes :first-child :last-child :nth-child (demystified)

    DOM hierarchy pseudo-classes allow you to style specific elements based on where they fall in the hi ...

  10. 详解Android动画之Frame Animation

    在开始实例讲解之前,先引用官方文档中的一段话: Frame动画是一系列图片按照一定的顺序展示的过程,和放电影的机制很相似,我们称为逐帧动画.Frame动画可以被定义在XML文件中,也可以完全编码实现. ...