您的位置:首页 > 大数据 > 人工智能

注册Jmail组件的三种方法

2008-11-28 18:27 375 查看
1、在命令行下执行:
    cmd
    regsvr32 jmail.dll

2、在安装程序中:
 public override void Install(System.Collections.IDictionary stateSaver)
  { 
   base.Install(stateSaver);
   try
   {
    /*
    在制作安装包时,自定义操作->安装,添加自定义操作(来自XX安装程序的主输出),配置
CustomerActionData=/targetdir="[TARGETDIR]/"
    */  
    string targetdir=this.Context.Parameters["targetdir"].Trim();
    if(!targetdir.EndsWith(@"/"))
        targetdir+=@"/";
   
   //注册Jmail组件
    try
    {
     JmailReg(targetdir);
    }
    catch(Exception)
    { }    
   }
   catch(Exception ex)
   {
    throw ex;
   }
 }

3、在Windows应用程序中:
private void DoUpdate()
  {
   string strPath=Application.StartupPath;
   IniFile ini = new IniFile(strPath+@"/sys.ini");
   //注册Jmail
   if(ini.IniReadValue("System","JmailReg").ToString()!="1")
   {
    JmailReg(strPath);
    ini.IniWriteValue("System","JmailReg","1");
   }
 }
private void JmailReg(string targetdir)
  {
   try
   {
    ProcessStartInfo processInfo =new ProcessStartInfo("regsvr32");
    //processInfo.WindowStyle=ProcessWindowStyle.Normal;
    processInfo.WindowStyle=ProcessWindowStyle.Hidden;
    processInfo.Arguments=" /s "+ Char.ToString('"') + targetdir + "jmail.dll"+Char.ToString('"');      
    Process osql = Process.Start(processInfo);
    //Wait till it is done...
    osql.WaitForExit();
    osql.Dispose();
    processInfo=null;
   }
   catch(Exception)
   {}
  }
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息