救命啊!出门就遇虎!

merkey2002 2003-08-24 10:30:35
刚学delphi,按着书上写的写入registry,
可是就是不行,why?
以下是代码。
unit Unit1;

interface

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

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

var
Form1: TForm1;

implementation
uses registry;

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
reg:tregistry;
buffer:pchar;
begin

buffer:='101010';
reg:=tregistry.Create ;
try
reg.RootKey :=hkey_current_user;
if reg.OpenKey('\test',true) then
begin
reg.WriteCurrency('currency',100);
reg.WriteBinaryData('binarydata',buffer,10);
end;
finally
reg.CloseKey ;
reg.Free ;


end;

end.
...全文
20 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
IORILI 2003-08-25
  • 打赏
  • 举报
回复
procedure Tdatamodule2.DataModuleCreate(Sender: TObject);
begin
//读ini文件
OpenDialog1.Filter:='WORD文档|*.doc|EXCEL文件|*.xls|所有文件|*.*';
IniFile := TIniFile.Create(GetIniFilePath);
ser_ip:=IniFile.ReadString('sever_ip', 'sever', '');
user_name:=inifile.readstring('user_name','default_name','');
user_pw:=inifile.readstring('user_pw','default_pw','');
dbname:=inifile.readstring('dbname','database','');
ftp_ip:=inifile.readstring('ftp_sever','ftp_ip','');
IniFile.Free;
getcomputerip(localip);
ADOConnection1.ConnectionString :=
'Provider=SQLOLEDB.1;Persist Security Info=false'
+ ';User ID=' + user_name
+ ';Initial Catalog=' + DBName
+ ';Data Source='+ser_ip
+ ';Use Procedure for Prepare=1;Auto Translate=True;Packet Size=4096'
+ ';Workstation ID='+localip
+ ';Use Encryption for Data=False'
+ ';Tag with column collation when possible=False';
datamodule2.NMFTP1.Host:=ftp_ip;
//连接数据库
//写ini文件
procedure Tsysshezhi.Button1Click(Sender: TObject);
begin
IniFile:=tinifile.Create(datamodule2.GetIniFilePath);
if (trim(edtaddress.Text)='') and (trim(ftpaddress.Text)='') then
begin
inifile.Free;
end else begin
if trim(edtaddress.Text)<>'' then
inifile.WriteString('sever_ip','sever',trim(edtAddress.Text));
if trim(ftpaddress.Text)<>'' then
inifile.WriteString('ftp_sever','ftp_ip',trim(ftpaddress.Text));
漠北刀客 2003-08-25
  • 打赏
  • 举报
回复
楼上说的很清楚了
walkmangood 2003-08-25
  • 打赏
  • 举报
回复
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls,registry//这里;


两个都要加地
walkmangood 2003-08-25
  • 打赏
  • 举报
回复
把registry加到uses
merkey2002 2003-08-24
  • 打赏
  • 举报
回复
这一段是写入ini文件的,也不行。FT啊。。。

unit Unit1;

interface

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

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

var
Form1: TForm1;

implementation

uses inifiles;

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var t:tinifile;
s:string;
begin
s:='ini_section';
try
t:=tinifile.Create('.\test.ini');
t.WriteBool(s,'bool',true);
finally
t.Free

end;

end.

5,386

社区成员

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

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