修改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窗口的标题的更多相关文章

  1. 对于windows窗口的标题菜单栏的操作——删除/禁用 最小最大话和关闭

    HWND hand = FindWindow(NULL, "计算器"); int nStyle = GetWindowLong(hand, GWL_STYLE);nStyle &a ...

  2. unity 实现调用Windows窗口/对话框交互

    Unity调用Window窗口 本文提供全流程,中文翻译. Chinar 坚持将简单的生活方式,带给世人!(拥有更好的阅读体验 -- 高分辨率用户请根据需求调整网页缩放比例) Chinar -- 心分 ...

  3. Windows 系统上用 .NET/C# 查找所有窗口,并获得窗口的标题、位置、尺寸、最小化、可见性等各种状态

    原文:Windows 系统上用 .NET/C# 查找所有窗口,并获得窗口的标题.位置.尺寸.最小化.可见性等各种状态 在 Windows 应用开发中,如果需要操作其他的窗口,那么可以使用 EnumWi ...

  4. CMD命令之 :修改windows的CMD窗口输出编码格式为UTF-8

    修改windows的CMD窗口输出编码格式为UTF-8 转载自 http://xuliduo.iteye.com/blog/639923 dos命令: chcp 65001  就是换成UTF-8代码页 ...

  5. 按键精灵 句柄 获得句柄 控制windows窗口 后台

    新建一个文本文档,打开,Windows就会给这个文本文档的窗口临时分配唯一的一串数字来标识这个窗体,以区别于其他窗口,这串数字就叫句柄.   因为句柄是临时随机分配的,所以每次虽然是打开同一个文件,但 ...

  6. windows窗口分析,父窗口,子窗口,所有者窗口

    (本文尝试通过一些简单的实验,来分析Windows的窗口机制,并对微软的设计理由进行一定的猜测,需要读者具备C++.Windows编程及MFC经验,还得有一定动手能力.文中可能出现一些术语不统一的现象 ...

  7. Windows窗口消息大全(转)

    Windows窗口消息大全,全不全自己看 ////////////////////////////////////////////////////////////////////////// #inc ...

  8. Windows窗口消息大全

    ////////////////////////////////////////////////////////////////////////// #include "AFXPRIV.H& ...

  9. C语言Windows程序开发—Windows窗口样式与常用控件样式【第04天】

    (一)Windows窗口(MDICLIENT)样式介绍 /* Windows窗口样式 */ WS_BORDER //带有边框的窗口 WS_CAPTION //带有标题栏的窗口 WS_CHILD //子 ...

随机推荐

  1. .Net 数据库(SqlServer2008)的备份、还原

    //备份代码private void Backup() { SqlConnection sqlConn = new SqlConnection(strConn); strFileName = &quo ...

  2. python学习手册 (第3版)

    第一部分 使用入门 第二部分 类型和运算 第三部分 语句和语法 第四部分 函数 第五部分 模块 第六部分 类和OOP 第七部分 异常和工具 第1章 问答环节 人们为何使用Python:可读性.一致性和 ...

  3. P1001

    原创 问题描述: 当两个比较大的整数相乘时,可能会出现数据溢出的情形.为避免溢出,可以采用字符串的方法来实现两个大数之间的乘法. 具体来说,首先以字符串的形式输入两个整数,每个整数的长度不会超过8位, ...

  4. Matrix和Camera配合实现3D效果

    一.Camera与Matrix简单介绍 1.Camera Android中一共有两个Camera,分别为:android.graphics.Camera android.hardware.Camera ...

  5. TSQL--删除正在运行的数据库

    ); SET @dbName='DB1_SNAP' BEGIN TRY --===================================== --查找当前数据库所有连接并删除 DECLARE ...

  6. 2张图简单分析count(0)与count(*)

    以前一直以为count(0)查询效率比count(*)比较高,原因大概是这么认为count(0)只是第一列进行统计,而count(*)所有列放在一起统计(亲,不要误会,这里不是所有列累加哦) 结果真的 ...

  7. 课后练习Javascript

    <script type="text/javascript"> alert (isNaN(prompt("输入个数字进来","只能输入数字 ...

  8. c#递归理解

    什么是递归函数? 任何一个方法既可以调用其他方法又可以调用自己,而当这个方法调用自己时,我们就叫它递归函数或者递归方法! 说白了,就是调用自己. 通常递归有两个特点:     1.递归方法一直会调用自 ...

  9. p2p_server

    以太坊系列之十九 对p2p模块server的理解 type transport interface { // The two handshakes. doEncHandshake(prv *ecdsa ...

  10. android android studio

     android studio 一.安装及步骤: Android Studio安装: java jdk安装: jdk环境变量配置: 二.遇到的问题: 1.缺少jvm或java jdk路径不对,请指定正 ...