gpt4 book ai didi

cmd - 从命令提示符启动时更改应用程序的标题

转载 作者:行者123 更新时间:2023-12-03 23:21:47 24 4
gpt4 key购买 nike

我是具有两个独立环境的应用程序的业务用户:测试和生产。重要的是我始终知道我在使用哪个环境,但应用程序没有给出任何指示。窗口标题、布局和所有功能都相同,程序中没有识别环境的功能,所以我有责任记住我当前使用的是哪个 .exe。

我想我可以修改快捷方式或使用命令提示符打开窗口,使标题清楚地显示“TEST”或“PRODUCTION”。

我尝试了以下操作,但是,当它按预期启动应用程序时,窗口标题没有变化。 (我怀疑这仅在启动命令提示符时有效)

start "different title" fake.exe

有没有办法做到这一点?任何想法将不胜感激。

最佳答案

您需要编写一个程序来执行此操作。

您需要调用 Windows 的 API。这是如何制作标题栏更改程序。

使用记事本创建一个文件并将其命名为 SetText.bas。将其存储在您的桌面上。

将其粘贴到其中。

Imports System
Imports System.Runtime.InteropServices
Imports Microsoft.Win32

Public Module MyApplication

Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Declare Function SetWindowText Lib "user32" Alias "SetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String) As Long

Sub Main()
On Error Resume Next
Dim CmdLine As String
Dim Ret as Long
Dim A() as String
Dim hwindows as long

CmdLine = Command()
If Left(CmdLine, 2) = "/?" Then
MsgBox("Usage:" & vbCrLf & vbCrLf & "ChangeTitleBar Oldname NewName")
Else
A = Split(CmdLine, Chr(34), -1, vbBinaryCompare)
hwindows = FindWindow(vbNullString, A(1))
Ret = SetWindowText(hwindows, A(3))

End If
End Sub
End Module

然后在命令提示符窗口中键入。
"C:\Windows\Microsoft.NET\Framework\v4.0.30319\vbc.exe" /target:winexe /out:"%userprofile%\desktop\SetText.exe" "%userprofile%\desktop\settext.bas" /verbose

在您的桌面上创建了一个名为 settext.exe 的程序。使用
"%userprofile%\desktop\settext" "Untitled - Notepad" "A Renamed Notepad"

关于cmd - 从命令提示符启动时更改应用程序的标题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39021975/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com