dcandygmailcom

SetWindowText.exe sets the titlebar text for a window

Feb 12th, 2019
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 1.38 KB | None | 0 0
  1. REM Two files follow
  2. REM SetWindowText.bat
  3. REM This file compiles SetWindowText.vb to SetWindowText.exe using the system VB.NET compiler.
  4. REM SetWindowText.exe sets the titlebar text for a window
  5. REM SetWindowText.exe "OldWindowTitle" "NewWindowTitle"
  6. REM EG Open notepad and type in a command prompt
  7. REM SetWindowText.exe "Untitled - Notepad" "My Window Title"
  8. "C:\Windows\Microsoft.NET\Framework\v4.0.30319\vbc.exe" /target:winexe /out:"%~dp0\SetWindowText.exe" "%~dp0\SetWindowText.vb" /verbose
  9. pause
  10.  
  11.  
  12.  
  13.  
  14. ------------------------------------------------------
  15.  
  16.  
  17. 'SetWindowText.vb
  18. Imports System
  19. Imports System.Runtime.InteropServices
  20. Imports Microsoft.Win32
  21.  
  22. Public Module MyApplication  
  23.  
  24.  
  25. Public Declare UNICODE Function FindWindowW Lib "user32" (ByVal lpClassName As String, ByVal lpWindowName As String) As IntPtr
  26.  
  27. Public Declare UNICODE Function SetWindowTextW Lib "user32" (ByVal hwnd As IntPtr, ByVal lpString As String) As Integer
  28.  
  29. Sub Main()
  30. On Error Resume Next
  31. Dim CmdLine As String
  32. Dim Ret as Integer
  33. Dim A() as String
  34. Dim hwindows as IntPtr
  35.  
  36. CmdLine = Command()
  37. If Left(CmdLine, 2) = "/?" Then
  38.     MsgBox("Usage:" & vbCrLf & vbCrLf & "SetText ""OldWindowTitle"" ""NewWindowTitle""")
  39. Else
  40.     A = Split(CmdLine, Chr(34), -1, vbBinaryCompare)
  41.     hwindows = FindWindowW(vbNullString, A(1))
  42.     Ret = SetWindowTextW(hwindows, A(3))
  43. End If
  44. End Sub
  45. End Module
Advertisement
Add Comment
Please, Sign In to add comment