(一)问题
项目开发中常会有开多个分支,同时启动多个 Unity 程序的情况,来回切换的时候就容易混淆,有时候还需要用 Show In Explorer 或者其他标志来确认当前使用的是哪个分支。
(二)代码
1. 声明要调用的系统接口
using System;
using System.Runtime.InteropServices;
using System.Text;
public partial class UpdateUnityEditorProcess
{
public delegate bool EnumThreadWindowsCallback(IntPtr hWnd, IntPtr lParam);
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
public static extern bool EnumWindows(EnumThreadWindowsCallback callback, IntPtr exTradata);
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
public static extern int GetwindowThreadProcessId(HandleRef handle, out int processId);
[DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
public static extern IntPtr Getwindow(HandleRef hWnd, int uCmd);
[DllImport("user32.dll", CharSet = CharSet.Auto)]
public static extern bool IsWindowVisible(HandleRef hWnd);
[DllImport("user32.dll")]
private static extern bool GetwindowText(int hWnd, StringBuilder title, int maxBufSize);
[DllImport("user32.dll", CharSet = CharSet.Auto)]
private extern static int GetwindowTextLength(IntPtr hWnd);
[DllImport("user32.dll", EntryPoint = "SetwindowText", CharSet = CharSet.Auto)]
public extern static int SetwindowText(int hwnd, string lpString);
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。