安装程序把序列号写到注册表,你的程序再读出来校验啊~~~~~~~~

解决方案 »

  1.   

    注册信息是安装结束时才写的注册表,可是我要在安装过程中读用户输入的序列号,这时注册表里还没有生成注册信息. 我是写在一个重载的类中install.
    是不是有个安装结束时的事件可以写啊
    protected string readRegistry()
    {
    string getValue="";
    try
    {
    RegistryKey regRead=Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\Userdata\S-1-5-21-1614895754-1677128483-1957994488-1004\Products\4E8612854008FA246980D2307BEAF89C\InstallProperties");
    getValue=(string)regRead.GetValue("ProductID");
    regRead.Close();
    }
    catch(Exception)
    {
       throw new InstallException("读注册表ProductID:"+getValue);
    } return getValue;
    }public override void Install(System.Collections.IDictionary stateSaver) 

    base.Install(stateSaver); 

    connstring="server=127.0.0.1;Integrated Security=SSPI;";
    try
    {
    //Security Lock Checking
    string ProductID=readRegistry();运行到此处读注册表出错
    //chkdog(getValue); //database operation
    sqlConnection1=new SqlConnection(connstring);
    AddDBTable(this.Context.Parameters["dbname"]); 

    //update the config file
    //ReplaceUserPwd("d:\\netxxzx\\wwwroot\\sdm_centerm\\Web.config",uid,pwd); //create virtual dir
    CreateVirtualDir();
    //regist com+
             //registCom();        }
           catch (Exception e)
          {   
    Console.Write("操作失败:"+e.Message); 
    throw e; 
    }}