Author: cwittich
Date: Thu Jan 31 13:05:02 2008
New Revision: 32063
URL:
http://svn.reactos.org/svn/reactos?rev=32063&view=rev
Log:
fix storing and loading registry settings
Modified:
trunk/rosapps/applications/screensavers/matrix/settings.c
Modified: trunk/rosapps/applications/screensavers/matrix/settings.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rosapps/applications/screensavers/…
==============================================================================
--- trunk/rosapps/applications/screensavers/matrix/settings.c (original)
+++ trunk/rosapps/applications/screensavers/matrix/settings.c Thu Jan 31 13:05:02 2008
@@ -35,7 +35,7 @@
if(hugechar == 0)
return;
- hugechar[0] = _T('\0');
+ ZeroMemory(hugechar, 4096);
RegCreateKeyEx(HKEY_CURRENT_USER, _T("Software\\Catch22\\Matrix Screen
Saver"), 0,
_T(""), 0, KEY_READ, NULL, &hkey, NULL);
@@ -71,21 +71,15 @@
if(ERROR_SUCCESS == RegQueryValueEx(hkey, _T("Randomize"), 0, 0, (BYTE
*)&value, &len))
g_fRandomizeMessages = (value == 0 ? FALSE : TRUE);
- len = 4096;
- if(ERROR_SUCCESS == RegQueryValueEx(hkey, _T("FontName"), 0, 0, (BYTE
*)hugechar, &len))
- {
- if(len > 0)
- lstrcpy(g_szFontName, hugechar);
- else
- lstrcpy(g_szFontName, _T("Arial"));
-
- }
+ len = 512;
+ if(RegQueryValueEx(hkey, _T("FontName"), 0, 0, (BYTE *)g_szFontName,
&len) != ERROR_SUCCESS)
+ lstrcpy(g_szFontName, _T("Arial"));
len = 4096;
if(ERROR_SUCCESS == RegQueryValueEx(hkey, _T("Messages"), 0, 0 , (BYTE
*)hugechar, &len))
{
- while(len > 0 && *hptr && isascii(*hptr))
+ while(len > 0 && *hptr && _istascii(*hptr))
{
if(lstrlen(hptr) > 0)
{
@@ -109,7 +103,7 @@
void SaveSettings()
{
HKEY hkey;
- TCHAR *hugechar = malloc(4096);
+ TCHAR *hugechar = malloc(4096 * sizeof(TCHAR));
TCHAR *msgptr = hugechar;
int totallen = 0;
int i,len;
@@ -118,7 +112,7 @@
if(hugechar == 0)
return;
- hugechar[0] = _T('\0');
+ ZeroMemory(hugechar, 4096 * sizeof(TCHAR));
msgptr = hugechar;
RegCreateKeyEx(HKEY_CURRENT_USER, _T("Software\\Catch22\\Matrix Screen
Saver"), 0,
@@ -142,7 +136,7 @@
value = g_fFontBold;
RegSetValueEx(hkey, _T("FontBold"), 0, REG_DWORD, (BYTE *)&value, sizeof
value);
- RegSetValueEx(hkey, _T("FontName"), 0, REG_SZ, (BYTE *)g_szFontName,
lstrlen(g_szFontName));
+ RegSetValueEx(hkey, _T("FontName"), 0, REG_SZ, (BYTE *)g_szFontName,
lstrlen(g_szFontName) * sizeof(TCHAR));
for(i = 0; i < g_nNumMessages; i++)
{
@@ -156,10 +150,10 @@
}
}
- *msgptr = _T('\0');
+ //*msgptr = _T('\0');
totallen++;
- RegSetValueEx(hkey, _T("Messages"), 0, REG_MULTI_SZ, (BYTE *)hugechar,
totallen);
+ RegSetValueEx(hkey, _T("Messages"), 0, REG_MULTI_SZ, (BYTE *)hugechar,
totallen * sizeof(TCHAR));
RegCloseKey(hkey);
free(hugechar);