mirror of
https://github.com/reactos/reactos.git
synced 2025-02-24 01:15:09 +00:00
- Bugfix: As szBuf was not null-terminated after the _tcscpy, the Processor Name String could have been wrapped wrong (ie. when it contained more spaces after character 30)
- Use a consistent indentation in SetProcNameString svn path=/trunk/; revision=27781
This commit is contained in:
parent
108a7ce988
commit
3087c56ea1
1 changed files with 78 additions and 75 deletions
|
@ -5,7 +5,7 @@
|
||||||
* PURPOSE: General System Information
|
* PURPOSE: General System Information
|
||||||
* COPYRIGHT: Copyright Thomas Weidenmueller <w3seek@reactos.org>
|
* COPYRIGHT: Copyright Thomas Weidenmueller <w3seek@reactos.org>
|
||||||
* Copyright 2006 Ged Murphy <gedmurphy@gmail.com>
|
* Copyright 2006 Ged Murphy <gedmurphy@gmail.com>
|
||||||
* Copyright 2006 Colin Finck <mail@colinfinck.de>
|
* Copyright 2006-2007 Colin Finck <mail@colinfinck.de>
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -118,83 +118,86 @@ SetProcNameString(HWND hwnd,
|
||||||
UINT uID1,
|
UINT uID1,
|
||||||
UINT uID2)
|
UINT uID2)
|
||||||
{
|
{
|
||||||
LPTSTR lpBuf = NULL;
|
LPTSTR lpBuf = NULL;
|
||||||
DWORD BufSize = 0;
|
DWORD BufSize = 0;
|
||||||
DWORD Type;
|
DWORD Type;
|
||||||
INT Ret = 0;
|
INT Ret = 0;
|
||||||
TCHAR szBuf[31];
|
TCHAR szBuf[31];
|
||||||
TCHAR* szLastSpace;
|
TCHAR* szLastSpace;
|
||||||
INT LastSpace = 0;
|
INT LastSpace = 0;
|
||||||
|
|
||||||
if (RegQueryValueEx(hKey,
|
if (RegQueryValueEx(hKey,
|
||||||
Value,
|
Value,
|
||||||
NULL,
|
NULL,
|
||||||
&Type,
|
&Type,
|
||||||
NULL,
|
NULL,
|
||||||
&BufSize) == ERROR_SUCCESS)
|
&BufSize) == ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
lpBuf = HeapAlloc(GetProcessHeap(),
|
lpBuf = HeapAlloc(GetProcessHeap(),
|
||||||
0,
|
0,
|
||||||
BufSize);
|
BufSize);
|
||||||
if (!lpBuf) return 0;
|
if (!lpBuf) return 0;
|
||||||
|
|
||||||
if (RegQueryValueEx(hKey,
|
if (RegQueryValueEx(hKey,
|
||||||
Value,
|
Value,
|
||||||
NULL,
|
NULL,
|
||||||
&Type,
|
&Type,
|
||||||
(PBYTE)lpBuf,
|
(PBYTE)lpBuf,
|
||||||
&BufSize) == ERROR_SUCCESS)
|
&BufSize) == ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
if(BufSize > ((30 + 1) * sizeof(TCHAR)))
|
if(BufSize > ((30 + 1) * sizeof(TCHAR)))
|
||||||
{
|
{
|
||||||
/* Wrap the Processor Name String like XP does: *
|
/* Wrap the Processor Name String like XP does: *
|
||||||
* - Take the first 30 characters and look for the last space. *
|
* - Take the first 30 characters and look for the last space. *
|
||||||
* Then wrap the string after this space. *
|
* Then wrap the string after this space. *
|
||||||
* - If no space is found, wrap the string after character 30. *
|
* - If no space is found, wrap the string after character 30. *
|
||||||
* *
|
* *
|
||||||
* For example the Processor Name String of a Pentium 4 is right-aligned. *
|
* For example the Processor Name String of a Pentium 4 is right-aligned. *
|
||||||
* With this wrapping the first line looks centered. */
|
* With this wrapping the first line looks centered. */
|
||||||
|
|
||||||
_tcsncpy(szBuf, lpBuf, 30);
|
_tcsncpy(szBuf, lpBuf, 30);
|
||||||
szLastSpace = _tcsrchr(szBuf, ' ');
|
szBuf[30] = 0;
|
||||||
|
szLastSpace = _tcsrchr(szBuf, ' ');
|
||||||
if(szLastSpace == 0)
|
|
||||||
LastSpace = 30;
|
|
||||||
else
|
|
||||||
LastSpace = (szLastSpace - szBuf);
|
|
||||||
|
|
||||||
_tcsncpy(szBuf, lpBuf, LastSpace);
|
|
||||||
szBuf[LastSpace] = 0;
|
|
||||||
|
|
||||||
SetDlgItemText(hwnd,
|
|
||||||
uID1,
|
|
||||||
szBuf);
|
|
||||||
|
|
||||||
SetDlgItemText(hwnd,
|
|
||||||
uID2,
|
|
||||||
lpBuf+LastSpace+1);
|
|
||||||
|
|
||||||
/* Return the number of used lines */
|
|
||||||
Ret = 2;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
SetDlgItemText(hwnd,
|
|
||||||
uID1,
|
|
||||||
lpBuf);
|
|
||||||
|
|
||||||
Ret = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
HeapFree(GetProcessHeap(),
|
if(szLastSpace == 0)
|
||||||
0,
|
LastSpace = 30;
|
||||||
lpBuf);
|
else
|
||||||
|
{
|
||||||
return Ret;
|
LastSpace = (szLastSpace - szBuf);
|
||||||
}
|
szBuf[LastSpace] = 0;
|
||||||
|
}
|
||||||
return 0;
|
|
||||||
|
_tcsncpy(szBuf, lpBuf, LastSpace);
|
||||||
|
|
||||||
|
SetDlgItemText(hwnd,
|
||||||
|
uID1,
|
||||||
|
szBuf);
|
||||||
|
|
||||||
|
SetDlgItemText(hwnd,
|
||||||
|
uID2,
|
||||||
|
lpBuf+LastSpace+1);
|
||||||
|
|
||||||
|
/* Return the number of used lines */
|
||||||
|
Ret = 2;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SetDlgItemText(hwnd,
|
||||||
|
uID1,
|
||||||
|
lpBuf);
|
||||||
|
|
||||||
|
Ret = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
HeapFree(GetProcessHeap(),
|
||||||
|
0,
|
||||||
|
lpBuf);
|
||||||
|
|
||||||
|
return Ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static VOID
|
static VOID
|
||||||
|
|
Loading…
Reference in a new issue