答案1
所以要明确的是 - 除非你编写代码来读取它,否则添加字符串表不会产生任何作用。
@Echo Off
Echo Two files follow
Echo SetWindowText.bat
Echo This file compiles SetWindowText.vb to SetWindowText.exe using the system VB.NET compiler.
Echo SetWindowText.exe sets the titlebar text for a window
Echo SetWindowText.exe "OldWindowTitle" "NewWindowTitle"
Echo EG Open notepad and type in a command prompt
Echo SetWindowText.exe "Untitled - Notepad" "My Window Title"
Echo ----------------------------------------------------------------------
"C:\Windows\Microsoft.NET\Framework\v4.0.30319\vbc.exe" /target:winexe /out:"%~dp0\SetWindowText.exe" "%~dp0\SetWindowText.vb"
pause
Imports System
Imports System.Runtime.InteropServices
Imports Microsoft.Win32
Public Module MyApplication
Public Declare UNICODE Function FindWindowW Lib "user32" (ByVal lpClassName As String, ByVal lpWindowName As String) As IntPtr
Public Declare UNICODE Function SetWindowTextW Lib "user32" (ByVal hwnd As IntPtr, ByVal lpString As String) As Integer
Sub Main()
On Error Resume Next
Dim CmdLine As String
Dim Ret as Integer
Dim A() as String
Dim hwindows as IntPtr
CmdLine = Command()
If Left(CmdLine, 2) = "/?" Then
MsgBox("Usage:" & vbCrLf & vbCrLf & "SetText ""OldWindowTitle"" ""NewWindowTitle""")
Else
A = Split(CmdLine, Chr(34), -1, vbBinaryCompare)
hwindows = FindWindowW(vbNullString, A(1))
Ret = SetWindowTextW(hwindows, A(3))
End If
End Sub
End Module
通常,默认窗口标题是 exe 文件的名称。程序往往会像上面一样更改它,要么直接通过 Windows API,要么间接通过其语言形式包。
如果您正在编写国际软件,您会将标题放入字符串表中,并在运行时读取它,然后更改标题。因此,不同的语言将使用不同的表。