有这么个需求,软件只能运行一个实例,软件运行后可以让其隐藏运行

再次运行这个软件的时候就让正在运行的实例显示出来

=================================

当软件隐藏后没办法拿到句柄

于是只有第一次运行的时候讲句柄保存下来,于是有了下面的

 1  private void HideForm()
 2         {
 3             string handlestr = System.Diagnostics.Process.GetCurrentProcess().MainWindowHandle.ToInt32().ToString();
 4             string path = Application.StartupPath + "\\Handle";
 5             if (!File.Exists(path))
 6             {
 7                 File.Create(path).Close();
 8             }
 9             using (StreamWriter writer = new StreamWriter(path, false))
10             {
11                 writer.Write(handlestr);
12             }
13             this.Hide();
14         }
View Code

相关文章:

  • 2022-03-05
  • 2022-12-23
  • 2021-06-26
  • 2021-12-19
  • 2021-09-21
  • 2022-12-23
  • 2021-04-30
猜你喜欢
  • 2022-12-23
  • 2022-03-05
  • 2021-08-20
  • 2022-03-02
  • 2021-09-06
  • 2022-03-06
相关资源
相似解决方案