ImageSQL/Program.cs
来源:互联网 发布:数据库远程访问工具 编辑:程序博客网 时间:2024/05/16 12:50
using System;
using System.Runtime.InteropServices;
using System.Threading;
using System.Windows.Forms;
using Microsoft.Win32;
namespace ImageSQL
{
static class Program
{
#region DllImportAttribute
[DllImport("user32.dll", EntryPoint = "ShowWindow")]
static extern bool ShowWindow(IntPtr handle, int flags);
[DllImport("user32.dll", EntryPoint = "SetForegroundWindow")]
static extern bool SetForegroundWindow(IntPtr handle);
#endregion
[STAThread]
static void Main()
{
#region Mutex
bool isCreated; // 互斥体名称须唯一。
using (Mutex newMutex = new Mutex(true, @"Local/ImageMSSQL", out isCreated))
{
if (isCreated)
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
using (RegistryKey subKey = Application.UserAppDataRegistry)
{
FormImageSQL frame = new FormImageSQL();
subKey.SetValue("Handle", frame.Handle);
Application.Run(frame);
}
newMutex.ReleaseMutex(); // 释放互斥体的所属权。
}
else
{
string text = string.Format("“{0}”应用程序已经运行。", AppDomain.CurrentDomain.FriendlyName);
MessageBox.Show(text, "系统提示!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
using (RegistryKey subKey = Application.UserAppDataRegistry)
{
IntPtr handle = new IntPtr(Convert.ToInt32(subKey.GetValue("Handle")));
ShowWindow(handle, 1);
SetForegroundWindow(handle);
}
}
}
#endregion
}
}
}
- ImageSQL/Program.cs
- ImageSQL/FormImageSQL.Designer.cs
- ImageSQL/FormImageSQL.cs
- Program.cs
- Program.cs
- ImageToAccess/Program.cs
- 我的一个Program.cs文件代码
- 新方法登录后窗体跳转【Program.cs】
- WinForm的Program.cs处理:全局异常&单例运行
- program
- Program
- program
- program
- PROGRAM
- Program
- program
- Program
- program
- 【转】 关于PL/SQL中对存储过程add debug information
- ImageSQL/FormImageSQL.cs
- indy安装
- XP没有IIS组件服务!
- Oracle10G Physical Standby Database笔记
- ImageSQL/Program.cs
- 【转】存储过程加密及解密
- Throughput of UTM Device Enhancements (Incomplete)
- dddddxz
- 告诉你C盘里的每个文件夹都是干什么用的!
- HTML事件
- jsp页面传值的乱码问题的解决
- ORACLE物化视图--循序渐进MView(二) MView Log的结构与快速刷新
- 学习linux的好书籍