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 ...
随机推荐
- zabbix通过jmx监控tomcat
Zabbix版本: Zabbix 3.0.2 一.服务端配置 1.安装jdk(版本1.7.0_79) 安装与配置比较简单,过程省略.执行java -version命令,出现类似界面表示成功. 2. ...
- Android webview中cookie增加/修改
最近项目需求中,需要满足往webview传递cookie,而且cookie需要增加修改: public class MainActivity extends Activity { private We ...
- Android环境rm命令
How can I execute all the possible unix(shell) commands in android programmatically? Android can't e ...
- CPLEX IDE 菜单栏语言设置( 中文 英文 韩文 等多国语言 设置)
http://www-01.ibm.com/support/docview.wss?uid=swg21573032 Technote (FAQ) Question How to change the ...
- win7IIS错误修改路径最全的
http://blog.csdn.net/testcs_dn/article/details/8726480 http://www.myexception.cn/asp-dotnet/1341569. ...
- Java 8 简明教程
欢迎阅读我编写的 Java 8 介绍.本教程将带领你一步步认识这门语言的所有新特性.通过简单明了的代码示例,你将会学习到如何使用默认接口方法,Lambda表达式,方法引用和可重复注解.在这篇教程的最后 ...
- Jackson中的那些坑
不符合驼峰规范的变量 “驼峰命名法”请自行百度.简单的来说就是变量的第一个单词以小写字母开始其他单词首字母大写,或者全部单词首字母都大写,分别称为“小驼峰”和“大驼峰” 比如一个符合驼峰规范命名的实体 ...
- Spring各种注解标签作用详解
@Autowired和@Resource等注解是将Spring容器中的bean注入到属性,而@Component等注解是将bean放入Spring容器中管理. @Autowired spring2.1 ...
- Pgsql数据库jsonb操作函数集合
CREATE OR REPLACE FUNCTION "json_object_del_path"( "json" json, "key_path&q ...
- 遮罩层的实现(纯js兼容版)
这个代码是我以前测试时候的代码了,主要用到的知识点是opacity和filer分别实现 “标准浏览器”和IE浏览器下的半透明,使用js的document.body.offsetwidth 和scree ...