如何向注册表内写入dword值,delphi提供的几个registry的写函数,没法实现,(100分)

  • 主题发起人 主题发起人 torrentwang
  • 开始时间 开始时间
T

torrentwang

Unregistered / Unconfirmed
GUEST, unregistred user!
如何向注册表内写入dword值,delphi提供的几个registry的写函数,没法实现,
常用的如writestring
writeblob,
writeinteger
如何写入dword类型的值呢
 
就是writeinteger啊! 把你的代码拿出来看看吧,估计是哪里出了问题,例如没有Openkey怎么着。
 
肯定就是用WriteInteger了。
void __fastcall TForm1::Button1Click(TObject *Sender)
{
TRegistry *reg;
DWORD d = 0xffffffff; //32位无符号长整形的最大值
reg = new TRegistry();
reg->RootKey = HKEY_LOCAL_MACHINE;
if (reg->OpenKey("SOFTWARE//SachowWorks", false)){
reg->WriteInteger("TestDWORD", d);
reg->CloseKey();
}
delete reg;
}
 
我的openkey之类肯定是成功的,
to Sachow 谢谢你的回答
最好是DELPHI的程序最好了
 
改一下就可以了:
void __fastcall TForm1::Button1Click(TObject *Sender)
{
TRegistry *reg;
DWORD d = 0xffffffff; //32位无符号长整形的最大值
reg = new TRegistry();
reg->RootKey = HKEY_LOCAL_MACHINE;
if (reg->OpenKey("SOFTWARE//SachowWorks", false)){
reg->WriteInteger("TestDWORD", d);
reg->CloseKey();
}
delete reg;
}
改后为:
Procedure TForm1.Button1Click(Sender:TObject);
var reg:TRegistry;
d:DWORD;
Begin
d:= 0xffffffff; //32位无符号长整形的最大值
reg:=TRegistry.create;
reg.RootKey:= HKEY_LOCAL_MACHINE;
if (reg.OpenKey('SOFTWARE/SachowWorks', false)) Then
begin
reg.WriteInteger("TestDWORD", d);
reg.CloseKey;
end;
reg.free;
End;
你自己试试吧!
 
"TestDWORD"还要改为'TestDWORD'才可以,在DELPHI中是没有""的,呵呵
 
你的delphi程序编译也通不过呀
 
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls,Registry;

type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

Procedure TForm1.Button1Click(Sender:TObject);
var reg:TRegistry;
d:DWORD;
Begin

reg:=TRegistry.create;
reg.RootKey:= HKEY_LOCAL_MACHINE;
if (reg.OpenKey('SOFTWARE/SachowWorks',true)) Then
begin
reg.WriteInteger('TestDWORD', d);
reg.CloseKey;
end;
reg.free;
End;

end.
测试通过,可写入Dword值, QQ:108438328
 
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls,Registry;

type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

Procedure TForm1.Button1Click(Sender:TObject);
var reg:TRegistry;
d:DWORD;
Begin
d:=111;//你把111改成222试一下?呵呵.......十进制的!
reg:=TRegistry.create;
reg.RootKey:= HKEY_LOCAL_MACHINE;
if (reg.OpenKey('SOFTWARE/SachowWorks',true)) Then
begin
reg.WriteInteger('TestDWORD', d);
reg.CloseKey;
end;
reg.free;
End;

end.
测试通过,可写入Dword值, QQ:108438328
 
可来QQ,我详细讲解!100分给吧!
 
其实DOWRD和INTEGER处理方法一样啊。用writeinteger就行了。
 
多人接受答案了。
 
后退
顶部