我刚刚编写了一个注册器,在工程文件中加了如下代码:
program Project1;uses
  Forms,Controls, Registry,
  Unit1 in 'Unit1.pas' {Form1},
  Unit2 in 'Unit2.pas' {Form2},
  Unit3 in 'Unit3.pas' {Form3},
  Unit4 in 'Unit4.pas' {Form4},
  Unit5 in 'Unit5.pas' {Form5},
  Unit6 in 'Unit6.pas' {Form6},
    Windows, Messages, SysUtils, Variants, Classes, Graphics,
  Dialogs, StdCtrls, jpeg, ExtCtrls;
{$R *.res}
var
  Myreg : TRegistry ;
  times : integer ;
begin
  Application.Initialize;
  
  Application.CreateForm(TForm1, Form1);
  Application.CreateForm(TForm2, Form2);
  Application.CreateForm(TForm3, Form3);
  Application.CreateForm(TForm4, Form4);
  Application.CreateForm(TForm5, Form5);
  Application.CreateForm(TForm6, Form6);  Myreg := TRegistry.Create ;
  Myreg.RootKey := HKEY_CURRENT_USER ;
  Myreg.OpenKey('software\jysoft\',true ) ;
  times := Myreg.ReadInteger('times');
  if times > 3 then
  begin
    ShowMessage('Too Times!' );
  end
  else if times <> 999 then
  begin
    Form6.ShowModal ;
  end
  else
  begin
    Application.Run;
  end;
  Myreg.Free ;end.
可是它说堆栈溢出,这是怎么一回事“”??谢谢各位了

解决方案 »

  1.   

    读取键值时,先用String型,然后再转换成数值型:
      times := StrToIntDef(Myreg.ReadString('times'),0);
      

  2.   


      Myreg := TRegistry.Create ;
      Myreg.RootKey := HKEY_CURRENT_USER ;
      Myreg.OpenKey('software\jysoft\',true ) ;
      times := Myreg.ReadInteger('times');  //到这里没什么问题
      if times > 3 then
      begin
        ShowMessage('Too Times!' );
      end else if times <> 999 then 
          Form6.ShowModal   //是否弹出这里时有问题?
        else 
          Application.Run; 
      Myreg.Free ;
      

  3.   


      添加Myreg := TRegistry.Create时候出现错误,就是完成注册表的写入来鉴别身份,和计算访问次数来实现访问次数的控制!
      

  4.   

    xzhifei(飞) 你的方法我试过了,不过不是那里的错误
      

  5.   

    还是要谢谢你的 xzhifei(飞)