You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

72 lines
3.1 KiB

using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Windows;
namespace PCScreenUpdate
{
/// <summary>
/// App.xaml 的交互逻辑
/// </summary>
public partial class App : Application
{
internal string info = "";
private LogHelper log = new LogHelper();
private void Application_Startup(object sender, StartupEventArgs e)
{
try
{
if (e.Args.Count() > 0)
{
log.WriteInfoFile("收到" + e.Args[0].ToString());
info = e.Args[0].ToString();
}
}
catch (Exception ex)
{
log.WriteInfoFile(ex.ToString());
}
//System.Security.Principal.WindowsIdentity identity = System.Security.Principal.WindowsIdentity.GetCurrent();
////创建Windows用户主题
//System.Windows.Forms.Application.EnableVisualStyles();
//System.Security.Principal.WindowsPrincipal principal = new System.Security.Principal.WindowsPrincipal(identity);
////判断当前登录用户是否为管理员
//if (!principal.IsInRole(System.Security.Principal.WindowsBuiltInRole.Administrator))
//{
// //创建启动对象
// System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
// //设置运行文件
// startInfo.FileName = System.Windows.Forms.Application.ExecutablePath;
// startInfo.WorkingDirectory = System.Windows.Forms.Application.ExecutablePath.Replace("\\", "/").Substring(0, System.Windows.Forms.Application.ExecutablePath.Replace("\\", "/").LastIndexOf("/"));//设置应用程序在其所在目录
// //设置启动参数
// startInfo.Arguments = String.Join(" ", e);
// //设置启动动作,确保以管理员身份运行
// startInfo.Verb = "runas";
// //如果不是管理员,则启动UAC
// //log.WriteLogFile("工作路径:" + startInfo.WorkingDirectory, "APPError");
// System.Diagnostics.Process.Start(startInfo);
// //退出
// System.Windows.Forms.Application.Exit();
//}
//else
{
MainWindow win = new MainWindow();
win.Show();
}
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
Application.Current.DispatcherUnhandledException += new System.Windows.Threading.DispatcherUnhandledExceptionEventHandler(Current_DispatcherUnhandledException);
}
private void Current_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
{
}
private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{
Exception ex = (Exception)e.ExceptionObject;
}
}
}