using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
using System.Diagnostics;
using System.EnterpriseServices.Internal;
namespace SPTools
{
/// <summary>
/// Windows工具
/// </summary>
public class Windows
{
public static bool Is64Bit()
{
string tmp = Environment.GetEnvironmentVariable("ProgramFiles(x86)");
return tmp != null && tmp != string.Empty;
}
public static void Run(string File)
{
System.Diagnostics.ProcessStartInfo si = new System.Diagnostics.ProcessStartInfo();
si.FileName = File;
si.Arguments = null;
si.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal;
si.UseShellExecute = true;
si.RedirectStandardOutput = false;
Process p = System.Diagnostics.Process.Start(si);
}
private const int SW_HIDE = 0;
private const int SW_SHOWNORMAL = 1;
private const int SW_SHOW = 5;
[System.Runtime.InteropServices.DllImport("User32.dll", CharSet = System.Runtime.InteropServices.CharSet.Auto)]
private static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
[System.Runtime.InteropServices.DllImport("User32.dll", CharSet = System.Runtime.InteropServices.CharSet.Auto)]
private static extern bool ShowWindow(IntPtr hwnd, int nCmdShow);
public static void ShowWindow(string className, string formName)
{
try
{
IntPtr h = FindWindow(className, formName);
ShowWindow(h, SW_SHOW);
}
catch
{
}
}
public static void HideWindow(string className, string formName)
{
try
{
IntPtr h = FindWindow(className, formName);
ShowWindow(h, SW_HIDE);
}
catch
{
}
}
public bool GacInstall(string AssemblyFullPath)
{
try
{
var objPub = new Publish();
objPub.GacInstall(AssemblyFullPath);
return true;
}
catch
{
}
return false;
}
public bool GacRemove(string AssemblyFullPath)
{
try
{
var objPub = new Publish();
objPub.GacRemove(AssemblyFullPath);
return true;
}
catch
{
}
return false;
}
}
}