请问HeyTommy,这段源码为什么出错,只有10分了!(10分)

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

thebluehouse

Unregistered / Unconfirmed
GUEST, unregistred user!
unit Unit1;

interface

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

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
TempReg:TRegistry;
TempValue:string;
begin
TempReg:=TRegistry.Create;
try
TempReg.RootKey:=HKEY_LOCAL_MACHINE;
if TempReg.OpenKey('/Software/Microsoft/Windows/CurrentVersion/',false) then
begin
if tempreg.ValueExists('ProductId') then
begin
TempValue:=TempReg.ReadString('ProductId');
checkbox1.state:=cbchecked;
end
else
ShowMessage('ProductID is not exist!');
end;
finally
TempReg.CloseKey;
TempReg.Free;
end;
end;

end.

 
呵呵,你还是夜猫所?:)

看了先!
 
这就是你整个单元的代码?
你自己看你的定义:
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

都没有checkbox1 ,
你在按钮中郎个用得了 checkbox1.state:=cbchecked;嘛?
 
OpenKey('/Software/Microsoft/Windows/CurrentVersion/',false)
这个错了,最前面的那个"/"不用要的
 
naughtboy:

用了也没错!!!
 
顶部