Wuyin.ShoesManager.Start 程序源代码(包括只启动一个实例及使用XP控件技术)

这段代码是无垠鞋业管理系统的启动程序。它会检查系统是否已运行该程序,若已运行则将其窗口置于前台。还会判断操作系统是否为XP,若为XP会进行相关处理。程序启动时可选择是否显示闪屏,之后进入登录界面,登录成功则启动主窗体。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\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 嘻哈呵嘿 阅读( ...) 评论( ...) 编辑 收藏

转载于:https://www.cnblogs.com/skyover/archive/2004/02/12/1219.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值