Changing Text in Start Button
Here is the code to change the text in the start button:
Code:
Option Strict Off
Public Class Form1
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, ByVal lpWindowName As String) As Integer
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" _
(ByVal hWnd1 As Integer, ByVal hWnd2 As Integer, ByVal lpsz1 As String, ByVal lpsz2 As String) As Integer
Private Declare Function SendMessageSTRING Lib "user32" Alias "SendMessageA" _
(ByVal hwnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As String) As Integer
Private Const WM_SETTEXT = &HC
Private Const WM_GETTEXT = &HD
Public Sub ChangeStartButtonText(ByVal str As String)
Try
Dim StartButton As Integer
Dim StartButtonText As Integer
Dim Caption As String
StartButton = FindWindow("Shell_TrayWnd", vbNullString)
StartButtonText = FindWindowEx(StartButton, 0&, "button", vbNullString)
Caption = Mid(str, 1, 5)
SendMessageSTRING(StartButtonText, WM_SETTEXT, 256, Caption)
Catch ex As Exception
End Try
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
ChangeStartButtonText(TextBox1.Text)
End Sub
End Class
WARNING! If you set the text to more than 5 characters it will be cut off.
If you like this code please rate it and leave feedback.
Thanks!
Re: Changing Text in Start Button
When the computer is turned off / reset, does windows retain the new word or does it get set back to 'Start'?
Re: Changing Text in Start Button
Aha i knew someone would ask that, but the answer is no unfortunately it will get set back to start but if you want i could make something that retains the word until you change it.
Re: Changing Text in Start Button
Solution: Everytime the start button is changed write the text to a file and then on form load make it change the start button text to the text from the file.
Make your program create a registry key here: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
As your programs directory.
Example:
Code:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim startvar As String
If IO.File.Exists("C:\text.txt") Then
startvar = IO.File.ReadAllText("C:\text.txt")
SetStartCaption(startvar)
'write to the registry here, cant be bothered working out how to if someone can it'll be greatly appreciated
End If
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
ChangeStartButtonText(TextBox1.Text)
IO.File.WriteAllText("C:\text.txt", TextBox1.Text)
End Sub
Re: Changing Text in Start Button
Re: Changing Text in Start Button
But automatically the name is resetting after certain mins.
Re: Changing Text in Start Button
For anyone that is just looking to do this for fun rather than wanting the VB code for it, you can follow this guide: http://www.theeldergeek.com/change_t...rt_button1.htm
It does not get reset when you restart your PC or anything and I did it once and used the system for months without any issues.