Unity 修改windows窗口的标题
修改windows窗口的标题名称,就是修改下图的东西:

第一种:
using UnityEngine;
using System;
using System.Runtime.InteropServices;
public class SetWindowText : MonoBehaviour
{
#region WIN32API
delegate bool EnumWindowsCallBack(IntPtr hwnd, IntPtr lParam);
[DllImport("user32", CharSet = CharSet.Unicode)]
static extern bool SetWindowTextW(IntPtr hwnd, string title);
[DllImport("user32")]
static extern int EnumWindows(EnumWindowsCallBack lpEnumFunc, IntPtr lParam);
[DllImport("user32")]
static extern uint GetWindowThreadProcessId(IntPtr hWnd, ref IntPtr lpdwProcessId);
#endregion
IntPtr myWindowHandle;
public void Start()
{
IntPtr handle = (IntPtr)System.Diagnostics.Process.GetCurrentProcess().Id; //获取进程ID
EnumWindows(new EnumWindowsCallBack(EnumWindCallback), handle); //枚举查找本窗口
SetWindowTextW(myWindowHandle, "测试代码"); //设置窗口标题
} bool EnumWindCallback(IntPtr hwnd, IntPtr lParam)
{
IntPtr pid = IntPtr.Zero;
GetWindowThreadProcessId(hwnd, ref pid);
if (pid == lParam) //判断当前窗口是否属于本进程
{
myWindowHandle = hwnd;
return false;
}
return true;
}
}
第二种:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Text;
using UnityEngine; public class NewBehaviourScript : MonoBehaviour { //Import the following.
[DllImport("user32.dll", EntryPoint = "SetWindowTextW", CharSet = CharSet.Unicode)]
public static extern bool SetWindowTextW(System.IntPtr hwnd, System.String lpString);
[DllImport("user32.dll", EntryPoint = "FindWindow")]
public static extern System.IntPtr FindWindow(System.String className, System.String windowName); public void Change()
{
//Get the window handle.
var windowPtr = FindWindow(null, "WindowTitleChange");//打包时的ProductName,找到名字是WindowTitleChange的窗口
//Set the title text using the window handle.
SetWindowTextW(windowPtr, "测试代码");
}
}
Unity 修改windows窗口的标题的更多相关文章
- 对于windows窗口的标题菜单栏的操作——删除/禁用 最小最大话和关闭
HWND hand = FindWindow(NULL, "计算器"); int nStyle = GetWindowLong(hand, GWL_STYLE);nStyle &a ...
- unity 实现调用Windows窗口/对话框交互
Unity调用Window窗口 本文提供全流程,中文翻译. Chinar 坚持将简单的生活方式,带给世人!(拥有更好的阅读体验 -- 高分辨率用户请根据需求调整网页缩放比例) Chinar -- 心分 ...
- Windows 系统上用 .NET/C# 查找所有窗口,并获得窗口的标题、位置、尺寸、最小化、可见性等各种状态
原文:Windows 系统上用 .NET/C# 查找所有窗口,并获得窗口的标题.位置.尺寸.最小化.可见性等各种状态 在 Windows 应用开发中,如果需要操作其他的窗口,那么可以使用 EnumWi ...
- CMD命令之 :修改windows的CMD窗口输出编码格式为UTF-8
修改windows的CMD窗口输出编码格式为UTF-8 转载自 http://xuliduo.iteye.com/blog/639923 dos命令: chcp 65001 就是换成UTF-8代码页 ...
- 按键精灵 句柄 获得句柄 控制windows窗口 后台
新建一个文本文档,打开,Windows就会给这个文本文档的窗口临时分配唯一的一串数字来标识这个窗体,以区别于其他窗口,这串数字就叫句柄. 因为句柄是临时随机分配的,所以每次虽然是打开同一个文件,但 ...
- windows窗口分析,父窗口,子窗口,所有者窗口
(本文尝试通过一些简单的实验,来分析Windows的窗口机制,并对微软的设计理由进行一定的猜测,需要读者具备C++.Windows编程及MFC经验,还得有一定动手能力.文中可能出现一些术语不统一的现象 ...
- Windows窗口消息大全(转)
Windows窗口消息大全,全不全自己看 ////////////////////////////////////////////////////////////////////////// #inc ...
- Windows窗口消息大全
////////////////////////////////////////////////////////////////////////// #include "AFXPRIV.H& ...
- C语言Windows程序开发—Windows窗口样式与常用控件样式【第04天】
(一)Windows窗口(MDICLIENT)样式介绍 /* Windows窗口样式 */ WS_BORDER //带有边框的窗口 WS_CAPTION //带有标题栏的窗口 WS_CHILD //子 ...
随机推荐
- DELPHI XE5 跨平台 Form ShowModal 官方示例
Calling ShowModal as an Anonymous Method on All Platforms procedure THeaderFooterForm.btnPickClick(S ...
- C#帮助类:MD5加密
/// <summary> /// MD5加密 /// </summary> public class Md5 { /// <summary> /// MD5加密 ...
- Daily translation 3th
Source url:http://www.nzherald.co.nz/education/news/article.cfm?c_id=35&objectid=11149719 //plac ...
- MVC进阶篇(一)——概览
前言 说到MVC,就得先说说框架是什么东西,MVC好多人都知道,是Model.view.controller,但是MVC到底是什么样的一个框架呢,好多人又说了是约定大于配置.下面我来说说我的理解. 内 ...
- winform发布桌面程序后提示需开启“目录浏览”
把发布文件里的publish.htm名字改为index.htm就好了
- 一些c++多线程习题
题目1:子线程循环 10 次,接着主线程循环 100 次,接着又回到子线程循环 10 次,接着再回到主线程又循环 100 次,如此循环50次,试写出代码 代码1: #include <iostr ...
- Django REST framework序列化
一.简介 Django REST framework是基于Django实现的一个RESTful风格API框架,能够帮助我们快速开发RESTful风格的API. 官网:https://www.djang ...
- 2. C/C++笔试面试经典题目二
1. C和C++中struct有什么区别? [参考答案] [解析]C中的struct没有保护行为,没有public,private,protected,内部不能有函数,但可以有函数指针. 2. C++ ...
- centos下安装memcached并设置开机自动启动-两种方法
方法一: 安装memcachedyum install memcached 启动服务并初始化service memcached start -p 11211 -l 127.0.0.1 -d 设置mem ...
- Docker - 使用 Nexus3 搭设私有 NuGet 仓库
目录 前言 NuGet Nexus 私有仓库 说明 安装 Nexus 拉取 Nexus 镜像 运行 Nexus Nexus NuGet 仓库简单使用 Nexus 默认帐号 Repositories 上 ...