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 ...
随机推荐
- wifi测试相关(iwconfig,WPA Supplicant用法)
iwconfig用法 1.打开无线网卡电源 iwconfig wlan0 txpower no 2.列出区域内的无线网络 iwconfig wlan0 scan 3.假设要连接到网络myhome(即e ...
- [C# 网络编程系列]专题四:自定义Web浏览器
转自:http://www.cnblogs.com/zhili/archive/2012/08/24/WebBrowser.html 前言: 前一个专题介绍了自定义的Web服务器,然而向Web服务器发 ...
- (转载)php获取form表单中name相同的表单项
(转载)http://hi.baidu.com/ruhyxowwzhbqszq/item/5fd9c8b9b594db47ba0e12a9 比如下面的表单: /*form.php*/ <form ...
- android学习——必学基础组件
android基础组件是一个Android的开发人员必须要了解,且深刻理解的东西: 1.应用程序基础 2.应用程序组件 2.1.活动(Activities) 2.2.服务(Services) 2.3. ...
- BASH小脚本
1.查找当前目录中所有大于500M的文件,把这些文件名写到一个文本文件中,并统计其个数. find ./ -size +500M -type f | tee file_list | wc -l 2.在 ...
- 在Raspberry配置优化安装LNMP环境总结
在Raspberry配置优化安装LNMP环境总结 apt-get update apt-get install nginx apt-get install php5-fpm php5-cli php5 ...
- Qualcomm 8X camera daemon进程浅析
Camera 先看一下抽象层的主要流程: 首先启动一个守护进程 int qcamsvr_start(void)( qcamsvr.c) { 1. server_fd = open(server_dev ...
- linux btp 服务器 端及客户端配置
Server端/etc/ntp.conf
- tail head命令
显示1.txt的最后2行 tail -2 1.txt 显示1.txt的最后1行 tail -n 1 1.txt tail -1 1.txt 显示1.txt的最后10行 tail 1. ...
- Java Apcahe的HTTPClient工具Http请求当请求超时重发
java Apcahe的HTTPClient工具Http请求当请求超时时底层会默认进行重发,默认重发次数为3次,在某些情况下为了防止重复的请求,需要将自动重发覆盖. 设置HTTP参数,设置不进行自动重 ...