不要找什么控件,多看看Help。//uses registryvar Reg: TRegistry; begin Reg := TRegistry.Create; try Reg.RootKey := HKEY_CURRENT_USER; if Reg.OpenKey('\Software\Microsoft\Windows\CurrentVersion\RunOnce', True) then Reg.WriteString('MyApp','"' + ParamStr(0) + '"'); finally Reg.CloseKey; Reg.Free; end;
其实你要知道的主要是注册表,而不是delphi
同意楼上 而且DELPHI中有该类
建议使用DELPHI本身的修改注册表的类。
使用API,你完全可以自己做一个REGEDIT,甚至访问网络注册表
* 如何用Delphi保存注册表中某一键之下的所有值? (2000.2.6) 答:在编写KeyGhost-键盘幽灵软件的时候,需要保存注册表中的某一键下的所有值.如果用Registry单元的SaveKey & LoadKey,感觉并不是太理想,原因如下: 1.生成的文件为二进制文件,不易修改。 2.生成的文件不能带扩展名,而且是隐含文件,还必须把隐含属性去掉,拷贝不方便。 3.在win2000/NT中使用LoadKey可能存在权限的问题(没试过) 。 在这之下,我改用Registry单元中的GetValueNames命令,并配合ExploreReg单元[软件下载]使用,效果很好。并且代码已经写成,不用随注册表的变化而修改源码,维护方便。 uses ExploreReg; var IniFile:textfile; Val:TstringList; Reg:TRegistry; R:TExploreReg; i:integer; begin Reg:=TRegistry.Create; try Val:=TStringList.Create; try Reg.RootKey:=HKEY_LOCAL_MACHINE; //注册表的主键值 if Reg.OpenKey('此处为键的位置',False) then begin Reg.GetValueNames(Val); assignfile(IniFile,extractfilepath(application.exename)+'KeyGhost.ini'); rewrite(IniFile); for i:=0 to Val.Count-1 do begin writeln(IniFile,Val.Strings[i]); res:=R.ReadValue(2,'此处为键的位置',Val.Strings[i]); if vartype(res) <> $000B then writeln(IniFile,res) else writeln(IniFile); end; closefile(IniFile); end; finally val.Free; end; finally Reg.Free; end; end;
* 如何用Delphi4/5在Windows2000/NT中的普通用户(权限最低)中修改注册表? (2000.2.4) 答:在编写KeyGhost-键盘幽灵软件的时候,为了能保证在Windows2000/NT中的普通用户中能随Windows2000/NT一同启动,需要用编程的方法来修改 KEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run 键值里的内容,但却发现无法修改。这是因为Windows2000/NT中的普通用户(权限最低)中无法修改注册表中的某些关键值(有些注册表内容可以修改)。后来改用打开注册表文件的方法,解决了此问题。源码如下:var f:TextFile; begin AssignFile(f,ExtractFilePath(Application.exename)+'StartNT.reg'); //把临时的注册表文件放到主程序的目录下 Rewrite(f); Writeln(f,'REGEDIT4'); Writeln(f); Writeln(f,'[HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run]'); Writeln(f,RegPath); CloseFile(f); //打开注册表文件 ShellExecute(0, 'open', PChar(ExtractFilePath(Application.exename)+'StartNT.reg'), nil, nil, SW_SHOWNORMAL); Erase(f); //删除注册表文件 end; function RegPath:ShortString; var ss,AppName:ShortString; i:Integer; begin ss:=''; AppName:=Application.ExeName; for i:=1 to Length(AppName) do begin ss:=ss+AppName[i]; if AppName[i]='\' then ss:=ss+'\'; end; RegPath:='"'+copy(ExtractFileName(AppName),1,length(ExtractFileName(application.exename))-4)+'"="'+ss+'"'; end;
http://www.csdn.net/expert/topic/93/93052.shtm
Reg: TRegistry;
begin
Reg := TRegistry.Create;
try
Reg.RootKey := HKEY_CURRENT_USER;
if Reg.OpenKey('\Software\Microsoft\Windows\CurrentVersion\RunOnce',
True)
then Reg.WriteString('MyApp','"' + ParamStr(0) + '"');
finally
Reg.CloseKey;
Reg.Free;
end;
而且DELPHI中有该类
答:在编写KeyGhost-键盘幽灵软件的时候,需要保存注册表中的某一键下的所有值.如果用Registry单元的SaveKey & LoadKey,感觉并不是太理想,原因如下:
1.生成的文件为二进制文件,不易修改。
2.生成的文件不能带扩展名,而且是隐含文件,还必须把隐含属性去掉,拷贝不方便。
3.在win2000/NT中使用LoadKey可能存在权限的问题(没试过) 。
在这之下,我改用Registry单元中的GetValueNames命令,并配合ExploreReg单元[软件下载]使用,效果很好。并且代码已经写成,不用随注册表的变化而修改源码,维护方便。
uses ExploreReg;
var
IniFile:textfile;
Val:TstringList;
Reg:TRegistry;
R:TExploreReg;
i:integer;
begin
Reg:=TRegistry.Create;
try
Val:=TStringList.Create;
try
Reg.RootKey:=HKEY_LOCAL_MACHINE; //注册表的主键值
if Reg.OpenKey('此处为键的位置',False) then
begin
Reg.GetValueNames(Val);
assignfile(IniFile,extractfilepath(application.exename)+'KeyGhost.ini');
rewrite(IniFile);
for i:=0 to Val.Count-1 do
begin
writeln(IniFile,Val.Strings[i]);
res:=R.ReadValue(2,'此处为键的位置',Val.Strings[i]);
if vartype(res) <> $000B then writeln(IniFile,res)
else writeln(IniFile);
end;
closefile(IniFile);
end;
finally
val.Free;
end;
finally
Reg.Free;
end;
end;
* 如何用Delphi4/5在Windows2000/NT中的普通用户(权限最低)中修改注册表? (2000.2.4)
答:在编写KeyGhost-键盘幽灵软件的时候,为了能保证在Windows2000/NT中的普通用户中能随Windows2000/NT一同启动,需要用编程的方法来修改 KEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run 键值里的内容,但却发现无法修改。这是因为Windows2000/NT中的普通用户(权限最低)中无法修改注册表中的某些关键值(有些注册表内容可以修改)。后来改用打开注册表文件的方法,解决了此问题。源码如下:var f:TextFile;
begin
AssignFile(f,ExtractFilePath(Application.exename)+'StartNT.reg'); //把临时的注册表文件放到主程序的目录下
Rewrite(f);
Writeln(f,'REGEDIT4');
Writeln(f);
Writeln(f,'[HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run]');
Writeln(f,RegPath);
CloseFile(f);
//打开注册表文件
ShellExecute(0, 'open', PChar(ExtractFilePath(Application.exename)+'StartNT.reg'), nil, nil, SW_SHOWNORMAL);
Erase(f); //删除注册表文件
end; function RegPath:ShortString;
var ss,AppName:ShortString;
i:Integer;
begin
ss:='';
AppName:=Application.ExeName;
for i:=1 to Length(AppName) do
begin
ss:=ss+AppName[i];
if AppName[i]='\' then ss:=ss+'\';
end;
RegPath:='"'+copy(ExtractFileName(AppName),1,length(ExtractFileName(application.exename))-4)+'"="'+ss+'"';
end;
重复创作。吃力不讨好,又浪费时间