ManagerUtil.cs 2.0 KB
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Forms;

namespace OnlineStore.XLRStore
{
    public class ManagerUtil
    {
        public static void AutoRun(string strName, bool value)
        {
            try
            {
                //创建启动对象 
                System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
                //设置运行文件
                startInfo.FileName = System.Windows.Forms.Application.StartupPath + "\\AuToRunManager.exe";
                //设置启动参数 
                startInfo.Arguments = String.Join(" ", new string[2] { strName, value.ToString() });
                //设置启动动作,确保以管理员身份运行
                startInfo.Verb = "runas";
                //如果不是管理员,则启动UAC 
                System.Diagnostics.Process.Start(startInfo);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
        public static Image M_Line;
        /// <summary>
        /// 是否已经初始化过了 
        /// </summary>
        public static bool IsInit = false;


        public static Image GetImage(string file)
        {
            Image result = null;
            if (File.Exists(file))
            {
                Image image = Image.FromFile(file);
                result = new System.Drawing.Bitmap(image);
                image.Dispose();
            }
            else
            {

            }
            return result;
        }
        public static void Init()
        {
            try
            {
                IsInit = true;
                M_Line = GetImage(Application.StartupPath + "\\image\\line.png"); 
            }
            catch (Exception ex)
            {
                Console.Write(ex.ToString());
            }
        }

    }
}