小弟刚刚学DELPHI,怎么搜索注册表,怎么改注册表啊?

x64873041 2003-10-09 08:03:12
注册表中的数据名称和数据数值
用什么东西,给个例子
...全文
117 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
foxmx 2003-10-10
  • 打赏
  • 举报
回复
下面程序是读出windows中所有的已安装的程序.你自己看一下,很容易的.
uses Registry;

procedure TForm1.Button1Click(Sender: TObject);
Var list,softList :TStringList;
Reg :TRegistry;
FPath,FKey,SubString:String;
i: integer;
begin
FPath := 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall';
FKey := 'DisplayName';
list := TStringList.Create;
softList := TStringList.Create;
Reg := TRegistry.Create;
try
Reg.RootKey := HKEY_LOCAL_MACHINE;
If Reg.OpenKey(FPath, False) then
Reg.GetKeyNames(List);
List.Sort;
List.BeginUpdate;
Reg.CloseKey;
If Reg.OpenKey(FPath, False) then
Edit1.Text := List[0];
//Edit1.Text := Reg.ReadString('DriverDesc');
Reg.CloseKey;
for i:=0 to List.Count-1 do begin
FPath := 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\'+List[i];
if (Reg.OpenKey(FPath,False)) and (Reg.ReadString(FKey)<>'') then
softList.Add(Reg.ReadString(FKey));
Reg.CloseKey;
end;//end for
finally
Reg.Free; // 用 Try..Finally 结构确保 REG 变量能够释放。
end;
softList.Sort;
ListBox1.Items:=softlist;
end;
bottom 2003-10-10
  • 打赏
  • 举报
回复
to:huojiehai(海天子)
你帮我看看老外的 这个软件要怎么做(关于注册表)
http://www.bwkj.net/bios/down3/regc.exe
huojiehai 2003-10-09
  • 打赏
  • 举报
回复
This OnClick event handler adds the value specified in the ValueforKey edit box to the registry key specified by the NameofKey edit box. If the named key does not already exist, it creates one. (Note that if you don抰 want to give the user a choice, this could be accomplished more simply by setting the CanCreate parameter of the OpenKey call to true).

procedure TForm1.Button1Click(Sender: TObject);
var
Reg: TRegIniFile;
begin
if Length(NameofKey.Text) or Length(ValueforKey.Text) <=0 then
Showmessage('Either the key name or value is missing.')
else begin
Reg:=TRegIniFile.Create('MyApp');
try
Reg.RootKey:=HKey_Local_Machine; // Section to look for within the registry
if not Reg.OpenKey(NameofKey.Text,False) then
if MessageDlg('The specified key does not exist, create it?'

,Mtinformation,[mbYes,mbNo],0)=mryes then
begin
Reg.CreateKey(NameofKey.Text);
if not Reg.OpenKey(NameofKey.Text,False) then
ShowMessage('Error in Opening Created Key')
else
Reg.WriteString('Main Section','Value1',ValueForKey.Text);
end
else
Reg.WriteString('Main Section','Value1',ValueForKey.Text);
finally

Reg.Free;
end;
end;
end;
huojiehai 2003-10-09
  • 打赏
  • 举报
回复
unction GetRegistryValue(KeyName: string): string;
var
Registry: TRegistry;
begin
Registry := TRegistry.Create(KEY_READ);
try
Registry.RootKey = HKEY_LOCAL_MACHINE;
// False because we do not want to create it if it doesn't exist
Registry.OpenKey(KeyName, False);
Result := Registry.ReadString('VALUE1');
finally
Registry.Free;
end;
end;
x64873041 2003-10-09
  • 打赏
  • 举报
回复
没有看懂,能否详细点?
我不懂电脑 2003-10-09
  • 打赏
  • 举报
回复
The following example retrieves a value from a registry entry.

#include <Registry.hpp>

AnsiString GetRegistryValue(AnsiString KeyName)
{
AnsiString S;
TRegistry *Registry = new TRegistry;
try
{
Registry->RootKey = HKEY_LOCAL_MACHINE;
// false because we do not want to create it if it doesn’t exist
Registry->OpenKey(KeyName, false);
S = Registry->ReadString("VALUE1");
}
__finally
{
delete Registry;
}
return S;

}

1,183

社区成员

发帖
与我相关
我的任务
社区描述
Delphi Windows SDK/API
社区管理员
  • Windows SDK/API社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧