Delphi Register
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的更多相关文章
- Delphi中register, pascal, cdecl, stdcall, safecall(转)
源:http://blog.sina.com.cn/s/blog_552c78120100hsr9.html 注: 使用错误,或者在该加的地方没有加,可能会出现"privileged ins ...
- Delphi之静态方法,虚方法virtual,动态dynamic,抽象abstract,消息
Delphi之静态方法,虚方法virtual,动态dynamic,抽象abstract,消息 http://www.cnblogs.com/zhwx/archive/2012/08/28/266055 ...
- Delphi 关键字详解[整理于 "橙子" 的帖子]
absolute //它使得你能够创建一个新变量, 并且该变量的起始地址与另一个变量相同. var Str: ]; StrLen: Byte absolute Str; //这个声明指定了变量 ...
- 转:Delphi 6 实用函数
来自: daocaoren0824, 时间: -- ::, ID: 再给你一份 程序员实用函数 {▎▎▎▎▎▎▎▎▎▎▎▎▎▎▎▎▎▎▎▎▎▎▎▎▎▎▎▎▎▎▎▎▎▎▎▎▎▎▎} {▎ ▎} {▎ 大 ...
- Delphi常用关键字用法详解
本文详细介绍了Delphi中常用的各个关键字名称及用法,供大家在编程过程中借鉴参考之用.详情如下: absolute: ? 1 2 3 4 5 6 7 8 9 10 //它使得你能够创建一个新变量, ...
- 【转】Delphi 关键字详解
absolute //它使得你能够创建一个新变量, 并且该变量的起始地址与另一个变量相同. var Str: string[32]; StrLen: Byte absolute Str; //这个声明 ...
- Delphi中window消息截获的实现方式(2)
Delphi是Borland公司提供的一种全新的WINDOWS编程开发工具.由于它采用了具有弹性的和可重用的面向对象Pascal(object-orientedpascal)语言,并有强大的数据库引擎 ...
- delphi控件属性大全-详解-简介
http://blog.csdn.net/u011096030/article/details/18716713 button 组件: CAPTION 属性 :用于在按钮上显示文本内容 Cancel ...
- Delphi Excel 操作大全
Delphi Excel 操作大全 (一) 使用动态创建的方法首先创建 Excel 对象,使用ComObj:var ExcelApp: Variant;ExcelApp := CreateOleObj ...
随机推荐
- Linux无线网络设置(wpa_supplicant的使用)
主机环境:Gentoo Linux 3.1.10 WPA Supplicant工具包可以让您连接到那些使用WPA的AP.因为还只是beta版,所以它的配置方法仍会常常变化——尽管如此,在大部分情况下它 ...
- suse系统卸载数据库实例
1.停止数据库: 2.执行以下命令: find $ORACLE_BASE/* -name '*[Tt][Ee][Ss][Tt]*' 其中TEST为数据库的实例名: 删除存在的文件: 3.删除/etc ...
- UART(串口)
(1)串行通信线路三种工作方式:单工通信.半双工通信.全双工通信 单工:单工就是指A只能发信号,而B只能接收信号,通信是单向的. 半双工:半双工就是指A能发信号给B,B也能发信号给A,但这两个过程不能 ...
- CSS---网络编程
CSS概述 CSS是层叠样式表(Cascading Style Sheets)用来定义网页的显示效果.可以解决html代码对样式定义的重复,提高了后期样式代码的可维护性,并增强了网页的显示效果功能.简 ...
- Bzoj 3747: [POI2015]Kinoman 线段树
3747: [POI2015]Kinoman Time Limit: 60 Sec Memory Limit: 128 MBSubmit: 553 Solved: 222[Submit][Stat ...
- useradd、passwd、userdel
useradd是新建用户 userdel -r 是删除用户 passwd是修改密码 groupadd是新建组 groupdel是删除组 useradd yonghu 为添加用户 echo " ...
- hdoj 3665 Seaside【最短路】
Seaside Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Sub ...
- 8-10-Exercise
链接:第三次练习 A.ZOJ 3203 Light Bulb 这道题............哎~既可以用数学直接推导出来,也可以三分求,还可以二分求~~~~ NO1.数学公式 这种方法搞的不是很清楚 ...
- 前端学习-使用JS库Leaflet.js生成世界地图并获取标注地址经纬度。
介绍:Leaflet是一个开源的JavaScript库,对移动端友好且对地图有很好的交互性. 大小仅仅只有 33 KB, 同时具有大多数地图所需要的特点. Leaflet设计的非常简单易懂, 同时具有 ...
- HTML头部<head>学习
元素是所有头部元素的容器. 元素包含了所有的头部标签元素.在 元素中你可以插入脚本(scripts), 样式文件(CSS),及各种meta信息. 以下标签都可以添加到 head 部分: 1.title ...