First of all, the following HowTo article doesn’t make sense. Justus and I just found out how you can rename the Start Button of Windows (XP, 2000 etc.).
(1) In the main function determine the handle of the Desktop Windows (see GetDesktopWindow). (2) Then enumerate all Child Windows of the Desktop (see EnumChildWindows) ’til you find the Start Button (by comparing the buttons Class and Name). (3) If you found the Start Button, just pass its handle to the well-known SetWindowText function. That’s it!
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
| int _tmain(int argc, _TCHAR* argv[])
{
HWND lhStartButton = NULL;
// get desktop window and enum child windows
HWND lhDesktopWindow = GetDesktopWindow();
EnumChildWindows(lhDesktopWindow, EnumChildProc, (LPARAM)&lhStartButton);
// set the start button's text
SetWindowText(lhStartButton, TEXT("Stop"));
return 0;
}
BOOL CALLBACK EnumChildProc(HWND hwnd, LPARAM lParam)
{
int liLength = 255;
BOOL lbResult = TRUE;
TCHAR *lpszClass = new TCHAR[liLength + 1];
TCHAR *lpszText = new TCHAR[liLength + 1];
// get window class name and text
GetClassName(hwnd, lpszClass, liLength);
GetWindowText(hwnd, lpszText, liLength);
// compare class name and text
if ( 0 == wcscmp(TEXT("Button"), lpszClass) &&
0 == wcscmp(TEXT("Start"), lpszText) )
{
lbResult = FALSE;
(*(HWND*)lParam) = hwnd;
}
delete[] lpszClass;
delete[] lpszText;
return lbResult;
} |
Anyways. Why not blogging senseless things?