如何在打包时,在注册表中写入程序安装时的时间?。。。。。。

时间:2021-06-16 15:38:47
小弟现在要做个使用版的程序,计划打包时在系统注册表中让安装程序自动写入安装时的日期。程序启动时,在注册表中查找安装日期,如果两时间之差在规定的范围内则启动程序,否则退出。
那位老大能帮助实现?

9 个解决方案

#1


在程序运行的时候判断是否已经存在相关的键如果没有就创建,如果有就判断!

#2


TRegistry类很容易用的,你看一下BCB的Help中的例子就明白了

#3


程序第一次启动的时候写入注册表

在启动就读注册表

TRegIniFile *Reg=new TRegIniFile("SOFTWARE");
  try
   { Reg->RootKey=HKEY_CURRENT_USER; // Section to look for within the registry
     if (!Reg->OpenKey("jsjd", false))
      { if (Application->MessageBox("现在就注册吗?","", MB_YESNO)==IDYES)
         { Reg->CreateKey("jsjd");
           if (!Reg->OpenKey("jsjd", false))
            ShowMessage("´Ëϵͳδע²á³É¹¦£¡£¡");
           else
            { Reg->WriteString("www", "Windows_No", Edit1->Text);
              Reg->WriteString("www", "dqmc", Edit2->Text);
              Reg->WriteString("www", "dqcode", Edit3->Text);
              Reg->WriteString("www", "yhmc", Edit4->Text);
              Reg->WriteString("www", "ctmt", Edit5->Text);
              Reg->WriteString("www", "wspb", Edit6->Text);
              Reg->WriteString("www", "jhct", Edit7->Text);
            }
         }
      }
     else
      { Reg->WriteString("www", "Windows_No", Edit1->Text);
        Reg->WriteString("www", "dqmc", Edit2->Text);
        Reg->WriteString("www", "dqcode", Edit3->Text);
        Reg->WriteString("www", "yhmc", Edit4->Text);
        Reg->WriteString("www", "ctmt", Edit5->Text);
        Reg->WriteString("www", "wspb", Edit6->Text);
        Reg->WriteString("www", "jhct", Edit7->Text);
      }
   }

#4


不是楼上各位兄弟的意思,我是想让打包程序在注册表中写入日期值。

#5


instrallsheild里面提供了这个功能,如果你想自己做,可以在instrallsheild的写注册表项里面添加进你的时间,用stringvalue吧,好像。

#6


建议程序第一次启动的时候写入注册表
在启动就读注册表

如果让打包程序在注册表中写入日期值,可能程序卸载时候会把这个健值删除,可能达不到你的要求。

#7


同意楼上,在系统启动时写入注册表,还可以增加一些辅助判断的值。

#8


你用什么打包也不说,软件不一样,方法肯定就不一样了!
install shield里resource里有操作注册表的项,试试就知道了!

建议自己写个小程序,在安装时自动运行去写相关的注册信息

#9


何必保存安装时间,保存首次运行时间得了



#1


在程序运行的时候判断是否已经存在相关的键如果没有就创建,如果有就判断!

#2


TRegistry类很容易用的,你看一下BCB的Help中的例子就明白了

#3


程序第一次启动的时候写入注册表

在启动就读注册表

TRegIniFile *Reg=new TRegIniFile("SOFTWARE");
  try
   { Reg->RootKey=HKEY_CURRENT_USER; // Section to look for within the registry
     if (!Reg->OpenKey("jsjd", false))
      { if (Application->MessageBox("现在就注册吗?","", MB_YESNO)==IDYES)
         { Reg->CreateKey("jsjd");
           if (!Reg->OpenKey("jsjd", false))
            ShowMessage("´Ëϵͳδע²á³É¹¦£¡£¡");
           else
            { Reg->WriteString("www", "Windows_No", Edit1->Text);
              Reg->WriteString("www", "dqmc", Edit2->Text);
              Reg->WriteString("www", "dqcode", Edit3->Text);
              Reg->WriteString("www", "yhmc", Edit4->Text);
              Reg->WriteString("www", "ctmt", Edit5->Text);
              Reg->WriteString("www", "wspb", Edit6->Text);
              Reg->WriteString("www", "jhct", Edit7->Text);
            }
         }
      }
     else
      { Reg->WriteString("www", "Windows_No", Edit1->Text);
        Reg->WriteString("www", "dqmc", Edit2->Text);
        Reg->WriteString("www", "dqcode", Edit3->Text);
        Reg->WriteString("www", "yhmc", Edit4->Text);
        Reg->WriteString("www", "ctmt", Edit5->Text);
        Reg->WriteString("www", "wspb", Edit6->Text);
        Reg->WriteString("www", "jhct", Edit7->Text);
      }
   }

#4


不是楼上各位兄弟的意思,我是想让打包程序在注册表中写入日期值。

#5


instrallsheild里面提供了这个功能,如果你想自己做,可以在instrallsheild的写注册表项里面添加进你的时间,用stringvalue吧,好像。

#6


建议程序第一次启动的时候写入注册表
在启动就读注册表

如果让打包程序在注册表中写入日期值,可能程序卸载时候会把这个健值删除,可能达不到你的要求。

#7


同意楼上,在系统启动时写入注册表,还可以增加一些辅助判断的值。

#8


你用什么打包也不说,软件不一样,方法肯定就不一样了!
install shield里resource里有操作注册表的项,试试就知道了!

建议自己写个小程序,在安装时自动运行去写相关的注册信息

#9


何必保存安装时间,保存首次运行时间得了