mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 17:12:57 +00:00
Implement removal of environment variables by removing all environment variables from the registry and re-adding the stored ones.
svn path=/trunk/; revision=30086
This commit is contained in:
parent
6033dd0e44
commit
495c4b799c
1 changed files with 78 additions and 5 deletions
|
@ -484,7 +484,14 @@ SetAllVars(HWND hwndDlg,
|
||||||
PVARIABLE_DATA VarData;
|
PVARIABLE_DATA VarData;
|
||||||
LV_ITEM lvi;
|
LV_ITEM lvi;
|
||||||
INT iItem;
|
INT iItem;
|
||||||
HKEY hk;
|
HKEY hKey;
|
||||||
|
DWORD dwValueCount;
|
||||||
|
DWORD dwMaxValueNameLength;
|
||||||
|
LPTSTR *aValueArray;
|
||||||
|
DWORD dwNameLength;
|
||||||
|
DWORD i;
|
||||||
|
TCHAR szBuffer[256];
|
||||||
|
LPTSTR lpBuffer;
|
||||||
|
|
||||||
memset(&lvi, 0x00, sizeof(lvi));
|
memset(&lvi, 0x00, sizeof(lvi));
|
||||||
|
|
||||||
|
@ -504,12 +511,78 @@ SetAllVars(HWND hwndDlg,
|
||||||
REG_OPTION_NON_VOLATILE,
|
REG_OPTION_NON_VOLATILE,
|
||||||
KEY_WRITE | KEY_READ,
|
KEY_WRITE | KEY_READ,
|
||||||
NULL,
|
NULL,
|
||||||
&hk,
|
&hKey,
|
||||||
NULL))
|
NULL))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Get the number of values and the maximum value name length */
|
||||||
|
if (RegQueryInfoKey(hKey,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
&dwValueCount,
|
||||||
|
&dwMaxValueNameLength,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL))
|
||||||
|
{
|
||||||
|
RegCloseKey(hKey);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dwValueCount > 0)
|
||||||
|
{
|
||||||
|
/* Allocate the value array */
|
||||||
|
aValueArray = GlobalAlloc(GPTR, dwValueCount * sizeof(LPTSTR));
|
||||||
|
if (aValueArray != NULL)
|
||||||
|
{
|
||||||
|
/* Get all value names */
|
||||||
|
for (i = 0; i < dwValueCount; i++)
|
||||||
|
{
|
||||||
|
dwNameLength = 256;
|
||||||
|
if (!RegEnumValue(hKey,
|
||||||
|
i,
|
||||||
|
szBuffer,
|
||||||
|
&dwNameLength,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL))
|
||||||
|
{
|
||||||
|
/* Allocate a value name buffer, fill it and attach it to the array */
|
||||||
|
lpBuffer = (LPTSTR)GlobalAlloc(GPTR, (dwNameLength + 1) * sizeof(TCHAR));
|
||||||
|
if (lpBuffer != NULL)
|
||||||
|
{
|
||||||
|
_tcscpy(lpBuffer, szBuffer);
|
||||||
|
aValueArray[i] = lpBuffer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Delete all values */
|
||||||
|
for (i = 0; i < dwValueCount; i++)
|
||||||
|
{
|
||||||
|
if (aValueArray[i] != NULL)
|
||||||
|
{
|
||||||
|
/* Delete the value*/
|
||||||
|
RegDeleteValue(hKey,
|
||||||
|
aValueArray[i]);
|
||||||
|
|
||||||
|
/* Free the value name */
|
||||||
|
GlobalFree(aValueArray[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Free the value array */
|
||||||
|
GlobalFree(aValueArray);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Loop through all variables */
|
/* Loop through all variables */
|
||||||
while(ListView_GetItem(hwndListView, &lvi))
|
while(ListView_GetItem(hwndListView, &lvi))
|
||||||
{
|
{
|
||||||
|
@ -518,14 +591,14 @@ SetAllVars(HWND hwndDlg,
|
||||||
if (VarData != NULL)
|
if (VarData != NULL)
|
||||||
{
|
{
|
||||||
/* Set the new value */
|
/* Set the new value */
|
||||||
if (RegSetValueEx(hk,
|
if (RegSetValueEx(hKey,
|
||||||
VarData->lpName,
|
VarData->lpName,
|
||||||
0,
|
0,
|
||||||
VarData->dwType,
|
VarData->dwType,
|
||||||
(LPBYTE)VarData->lpRawValue,
|
(LPBYTE)VarData->lpRawValue,
|
||||||
(DWORD)(_tcslen(VarData->lpRawValue) + 1) * sizeof(TCHAR)))
|
(DWORD)(_tcslen(VarData->lpRawValue) + 1) * sizeof(TCHAR)))
|
||||||
{
|
{
|
||||||
RegCloseKey(hk);
|
RegCloseKey(hKey);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -535,7 +608,7 @@ SetAllVars(HWND hwndDlg,
|
||||||
lvi.iItem = ++iItem;
|
lvi.iItem = ++iItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
RegCloseKey(hk);
|
RegCloseKey(hKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue