嘻哈人间,我醉逍遥

while(true){this.StudyDotNet(DotNetLanguage.CSharp);}

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

using System;
using System.IO;
using System.Windows.Forms;
using System.Diagnostics;

namespace Wuyin.ShoesManager
{
 ///


 /// Start 的摘要说明。
 ///

 public class Start
 {
  static FlashScreen fs = null;
  static string[] commandLineArgs = null;
  static bool isTest = false;
  static bool isXp = false;

  public static bool IsInXp
  {
   get
   {
    return isXp;
   }
  }

   public static FlashScreen flashScreen
  {
   get
   {
    return fs;
   }
  }

  public static string[] CommandLineArgs
  {
   get
   {
    return commandLineArgs;
   }
  }

  public Start()
  {
   //
   // TODO: 在此处添加构造函数逻辑
   //
  }

  private static void ShowFocusWindow(int hwnd)
  {
   CommonClass.ShowWindow(hwnd,CommonClass.nCmdShow.SW_SHOW);
   CommonClass.SetForegroundWindow(hwnd);
  }

  [STAThread]
  public static void Main(string[] args)
  {
   bool noLogo = false;
   commandLineArgs = args;

   int hwnd = CommonClass.FindWindow(null,"无垠鞋业管理系统 - 登录");
   if(hwnd>0)
   {
    ShowFocusWindow(hwnd);
    return;
   }

   Process[] Procs = Process.GetProcesses();
   foreach(Process P in Procs)
   {
    string title = P.MainWindowTitle;
    if(title.StartsWith("无垠鞋业管理系统"))
    {
     hwnd = CommonClass.FindWindow(null,P.MainWindowTitle);
     ShowFocusWindow(hwnd);
     return;
    }
   }


   //如果在XP下则使用CommonControl 6 控件
   if(Environment.OSVersion.Version.Major > 4 & Environment.OSVersion.Version.Minor > 0 )
   {
    isXp = true;  
    if(!File.Exists(Application.ExecutablePath + ".manifest"))
    {
     StreamWriter sr = new StreamWriter(Application.ExecutablePath + ".manifest");
     sr.Write("\n\n\n.NET control deployment tool\n\n   \n     \n   \n\n");
     sr.Close();
     
     System.Diagnostics.Process P = System.Diagnostics.Process.Start(Application.ExecutablePath);
     
     Application.ExitThread();
     Application.Exit();
     return;
    }
   }

   foreach(string arg in args)
   {
    if(arg.ToUpper().EndsWith("NOLOGO"))
    {
     noLogo = true;
    }
    if(arg.ToUpper().EndsWith("/TEST"))
     isTest=true;
   }

   //显示SplashForm
   if(!noLogo)
   {
    fs = new FlashScreen();
    fs.Show();
   }

   //登录
   Wuyin.ShoesManager.frmLogin frm=new frmLogin();
   CommonClass.RecursivelyFormatForWinXP(frm);
   DialogResult result = frm.ShowDialog();
   if(result!=DialogResult.Yes)
   {
    frm.Close();
    if(fs!=null)
     fs.Close();
    Application.Exit();
   }
   else
   {
    frm.Close();
    StartMainForm();
   }
  }

  private static void StartMainForm()
  {
   fs.HideForm();
   if(!isTest)
    Application.Run(main.GetMainWindow);
   else
    Application.Run(new Form1());
  }
 }
}

posted on 2004-02-12 20:10  嘻哈呵嘿  阅读(762)  评论(1编辑  收藏  举报
欢迎访问无垠IT教学网论坛