CBC中写注册表使程序开机自动运行的方法

类别:编程语言 点击:0 评论:0 推荐:
#include <Registry.hpp>
 
TRegistry *Reg=new TRegistry();
  try
  {
    Reg->RootKey=HKEY_LOCAL_MACHINE;
    Reg->OpenKey("\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run\\",false);
    if(!Reg->ValueExists("wz"))
    {
      Reg->WriteString("wz",ExpandFileName(Application->ExeName));
    }
    else
    {
      if(Reg->ReadString("wz")!=ExpandFileName(Application->ExeName))
      {
        Reg->WriteString("wz",ExpandFileName(Application->ExeName));
      }
     }
    }
    __finally
    {
      delete Reg;
    }
正文 

本文地址:http://com.8s8s.com/it/it25678.htm