Carnac/Utilities/ProcessUtilities.cs
(开头部分) 2KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Threading;
using System.Windows;
namespace Carnac.Utilities
{
public static class ProcessUtilities
{
private static Mutex mutex = null;
[DllImport("user32.dll", SetLastError = true)]
static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
static extern bool SetForegroundWindow(IntPtr hWnd);
[DllImport("user32.dll")]
static extern bool IsIconic(IntPtr hWnd);
[DllImport("user32.dll")]
static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
const int SW_RESTORE = 9;
[DllImport("user32.dll")]
static extern IntPtr GetLastActivePopup(IntPtr hWnd);
[DllImport("user32.dll")]
static extern bool IsWindowEnabled(IntPtr hWnd);
/// Determine if the current process is already running
public static bool ThisProcessIsAlreadyRunning()
{
bool createdNew;
mutex = new Mutex(false, Application.Current.MainWindow.GetType().Assembly.FullName, out createdNew);
return !createdNew;
}
/// Set focus to the previous instance of the specified program.
public static void SetFocusToPreviousInstance(string windowCaptionPart)
{
var hWnd = IntPtr.Zero;
foreach (var process in Process.GetProcesses())
{
if (process.MainWindowTitle.Contains(windowCaptionPart))
{
hWnd = process.MainWindowHandle;
}
}
// Look for previous instance of this program.
//IntPtr = FindWindow(null, windowCaption);
// If a previous instance of this program was found...
if (hWnd != null)
{
// Is it displaying a popup window?
var hPopupWnd = GetLastActivePopup(hWnd);
// If so, set focus to the popup window. Otherwise set focus
后面还有 16 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。