追寻人生

学习之园地,创意之源泉

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

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)
   {}
  }

posted on 2008-01-08 10:51  追梦华仔  阅读(3412)  评论(1编辑  收藏  举报