Create your Gitee Account
Explore and code with more than 12 million developers,Free private repositories !:)
Sign up
文件
Clone or Download
Program.cs 1.59 KB
Copy Edit Raw Blame History
jincheng.zhu authored 2024-10-31 16:03 . V1.0.7.1
using PP.PaintLib;
using System;
using System.Diagnostics;
using System.Windows.Forms;
namespace MyPaint
{
static class Program
{
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
//启动程序
var progress1=GetExistProcess();
if (progress1 != null)
{
IntPtr mainWindowHandle1 = progress1.MainWindowHandle;
if (mainWindowHandle1 == IntPtr.Zero)//窗口被隐藏了
{
//目标窗体的 Text 属性中的字符串
mainWindowHandle1 = PPWin32.FindWindow(null, "PP画图");
}
PPWin32.ShowWindowAsync(mainWindowHandle1, 1);
PPWin32.SetForegroundWindow(mainWindowHandle1);
}
else
{
Application.Run(new MainForm());
}
}
/// <summary>
/// 查看程序是否已经运行
/// </summary>
/// <returns></returns>
private static Process GetExistProcess()
{
Process currentProcess = Process.GetCurrentProcess();
foreach (Process process1 in Process.GetProcessesByName(currentProcess.ProcessName))
{
if (process1.Id != currentProcess.Id)
{
return process1;
}
}
return null;
}
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化