Wuyin.ShoesManager.Start 程序源代码(包括只启动一个实例及使用XP控件技术)
2004-02-12 20:10
651 查看
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());
}
}
}
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());
}
}
}
相关文章推荐
- 几个比较好用的Windows API在C#中的用法。
- 利用radio实现Datagrid的单选
- 一个不错的代码编辑工具
- 测试实践:Eclipse 之 JUnit(一)
- 巧用GC
- 用Delphi模拟组件的两阶段提交
- 测试实践:Eclipse 之 JUnit(二)
- 使用java生成pdf文档
- 使用java生成pdf文档(2)
- .net入门之VB篇:Visual Basic.Net中的文件操作(一)
- 在信息系统中使用Java访问SQLServer数据库
- 模糊:让你的代码远离偷窥之眼
- ASP.NET Pre-Compilation and Keep-Alive
- Writing ASP.NET Web Forms with C#
- ASP.NET 验证机制
- ASP.NET中的事务处理和异常处理
- 最佳ASP.NET编程习惯
- ASP.NET图象处理详解
- ASP.NET读取POP3邮件的操作
- ASP.NET上传文件的实例