API函数

yifan1008 2003-08-21 09:36:36
谁给我找来二个读写注册表API函数,说出它们的格式,就有分。。
...全文
38 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
DJ_KK 2003-08-21
  • 打赏
  • 举报
回复
资料多,但还是学习
hongqi162 2003-08-21
  • 打赏
  • 举报
回复
从注册表关键字中读出相关的数据值 在Tregistry类中还提供了与Write方法相对应用的用来读出与当前关键字相关的数据值。常用方法的原型定义如下:
founction ReadString(const Name : string) : string;
founction ReadInteger(const Name : string) : Integer;
founction ReadFloat(const Name : string) : Double;
founction ReadTime(const Name : string) : TdateTime;
founction ReadBool(const Name) : Boolean;
示例程序如下:
procedure TForm1.Button1Click(Sender: TObject); var MyReg : TRegistry;
begin
MyReg := TRegistry.Create;
MyReg.RootKey := HKEY_LOCAL_MACHINE;
try
if not MyReg.OpenKey('\SOFTWARE\',FALSE) then
if not MyReg.KeyExists('Passwd') then
if not MyReg.OpenKey('\SOFTWARE\Passwd',FALSE) then
Label1.Caption := MyReg.ReadString('pwd1');
Label2.Caption := IntToStr(MyReg.ReadInteger('pd2'));
MyReg.CloseKey;
Finally
MyReg.Free;
end;
end;
koma2003 2003-08-21
  • 打赏
  • 举报
回复
声明一个TRegistry类型的变量,函数就跟INI文件操作差不多
记得要uses registry
hongqi162 2003-08-21
  • 打赏
  • 举报
回复
向注册表关键字中写入相关的数据值 在Tregistry类中提供了一系列的Write方法用来写入与当前关键字相关的数据值。常用方法的原型定义如下:
procedure WriteString(const Name, Value : string);
procedure WriteInteger(const Name : string ; Value : Integer);
procedure WriteFloat(const Name : string ; Value : Double);
procedure WriteTime(const Name : string ; Value : TDateTime);
procedure WriteBool(const Name : string ; Value : Boolean);
示例代码:
procedure TForm1.Button1Click(Sender: TObject); var MyReg : TRegistry;
begin
MyReg := TRegistry.Create;
MyReg.RootKey := HKEY_LOCAL_MACHINE;
try
if not MyReg.OpenKey('\SOFTWARE\',FALSE) then
if not MyReg.KeyExists('Passwd') then
MyReg.CreateKey('Passwd');
If not MyReg.OpenKey('\SOFTWARE\Passwd',FALSE) then MyReg.WriteString('pwd1','mypassword1');
MyReg.WriteInteger('pd2',19642);
MyReg.CloseKey;
finally
MyReg.Free;
end;
end;
nxyc_twz 2003-08-21
  • 打赏
  • 举报
回复
楼上说的不错!其实网上这方面的资料特别多!
lvloj 2003-08-21
  • 打赏
  • 举报
回复
RegOpenKeyEx
RegCloseKey
RegCreateKeyEx
RegDeleteKey
RegDeleteValue
在Delphi的帮助里面搜索上面的名称,很详细.

5,386

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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