aqiruse
October 7th, 1999, 10:39 PM
I am trying to enumerate a section of the registry. Lets say that the section I am dealing
with has 15 subkeys, each of those have 3 subkeys, and each of those have 2 more. The
problem is when I attempt to enum the registry, it will read the first subkey of the 15,
then the first subkey of the 3, then the first of the 2
and then the app stops. That leaves me with alot missing. If I change afew things, then it will
return the top 15 subkeys, but will not enter into any of the layers. This is what I am trying.
Any ideas as to what is wrong?
if (lreg != ERROR_SUCCESS)
{
return;
}
if (lreg == ERROR_SUCCESS)
{
DWORD cnt;
CString val;
valname = val.GetBuffer(val.GetLength() + 20);
regResult =RegQueryInfoKey(hKeyResult,
clsbuf,
&dwclsBufsize,
NULL,
&dwsubBufsize,
&dwMaxsubbufsize,
&dwMaxclsbufsize,
&dwValnumbuf,
&dwMaxValname,
&dwMaxValdata,
NULL,
&lastWrite);
nIndex++;
for (dwCount=0, lreg = ERROR_SUCCESS;
lreg == ERROR_SUCCESS; dwCount++)
{
// Set values
CString buf;
subbuf = buf.GetBuffer(buf.GetLength() + 20);
clsbuf = buf.GetBuffer(buf.GetLength() + 20);
DWORD subkeySize;
HKEY htemp = hKeyResult;
LPTSTR temp = subbuf;
subkeySize = dwMaxsubbufsize+1;
subbuf = new TCHAR[subkeySize];
DWORD dwCnt;
cnt = dwCount;
// End set values
// Enum keys
lreg = RegEnumKeyEx(hKeyResult,
dwCount,
subbuf,
&subkeySize,
NULL,
clsbuf,
&dwclsBufsize,
&lastWrite);
// Send name of keys to list
refCtrl.InsertItem(dwCount, (LPCTSTR)subbuf);
refCtrl.SetItem(dwCount, 1, LVIF_TEXT,
(LPCTSTR)clsbuf, NULL,
LVIS_SELECTED, -1, NULL);
refCtrl.UpdateWindow();
// End list items
if (dwValnumbuf != 0 && lreg == ERROR_SUCCESS)
{
for (dwCnt = 0; dwCnt < dwValnumbuf; dwCnt++)
{
//declare variables
valname = '\0';
vallength = dwMaxValname+1;
databufsize=dwMaxValdata+1;
char databuf[200];
CString data;
LPCTSTR valdata;
// Enum values
lreg = RegEnumValue(hKeyResult,
dwCnt,
valname,
&vallength,
NULL,
&dwRegType,
(LPBYTE)databuf,
&databufsize);
//Convert value data to readable item,
// then add to list
data = (LPSTR)databuf;
valdata = data.GetBuffer(data.GetLength());
// Send name of keys to list
refCtrl.SetItem(dwCnt, 2, LVIF_TEXT,
(LPCTSTR)valname, NULL,
LVIS_SELECTED, -1, NULL);
refCtrl.SetItem(dwCnt, 3, LVIF_TEXT,
(LPCTSTR)valdata, NULL,
LVIS_SELECTED, -1, NULL);
refCtrl.UpdateWindow();
// End list items
}
}
//Enum here ???
while (cnt > 0)
{
cnt--;
char * sub = "";
lstrcat(sub, "\\");
lstrcat(sub, subbuf);
subbuf = sub;
EnumReg(hKeyResult, subbuf);
}
}
}
RegCloseKey(hKeyResult);
with has 15 subkeys, each of those have 3 subkeys, and each of those have 2 more. The
problem is when I attempt to enum the registry, it will read the first subkey of the 15,
then the first subkey of the 3, then the first of the 2
and then the app stops. That leaves me with alot missing. If I change afew things, then it will
return the top 15 subkeys, but will not enter into any of the layers. This is what I am trying.
Any ideas as to what is wrong?
if (lreg != ERROR_SUCCESS)
{
return;
}
if (lreg == ERROR_SUCCESS)
{
DWORD cnt;
CString val;
valname = val.GetBuffer(val.GetLength() + 20);
regResult =RegQueryInfoKey(hKeyResult,
clsbuf,
&dwclsBufsize,
NULL,
&dwsubBufsize,
&dwMaxsubbufsize,
&dwMaxclsbufsize,
&dwValnumbuf,
&dwMaxValname,
&dwMaxValdata,
NULL,
&lastWrite);
nIndex++;
for (dwCount=0, lreg = ERROR_SUCCESS;
lreg == ERROR_SUCCESS; dwCount++)
{
// Set values
CString buf;
subbuf = buf.GetBuffer(buf.GetLength() + 20);
clsbuf = buf.GetBuffer(buf.GetLength() + 20);
DWORD subkeySize;
HKEY htemp = hKeyResult;
LPTSTR temp = subbuf;
subkeySize = dwMaxsubbufsize+1;
subbuf = new TCHAR[subkeySize];
DWORD dwCnt;
cnt = dwCount;
// End set values
// Enum keys
lreg = RegEnumKeyEx(hKeyResult,
dwCount,
subbuf,
&subkeySize,
NULL,
clsbuf,
&dwclsBufsize,
&lastWrite);
// Send name of keys to list
refCtrl.InsertItem(dwCount, (LPCTSTR)subbuf);
refCtrl.SetItem(dwCount, 1, LVIF_TEXT,
(LPCTSTR)clsbuf, NULL,
LVIS_SELECTED, -1, NULL);
refCtrl.UpdateWindow();
// End list items
if (dwValnumbuf != 0 && lreg == ERROR_SUCCESS)
{
for (dwCnt = 0; dwCnt < dwValnumbuf; dwCnt++)
{
//declare variables
valname = '\0';
vallength = dwMaxValname+1;
databufsize=dwMaxValdata+1;
char databuf[200];
CString data;
LPCTSTR valdata;
// Enum values
lreg = RegEnumValue(hKeyResult,
dwCnt,
valname,
&vallength,
NULL,
&dwRegType,
(LPBYTE)databuf,
&databufsize);
//Convert value data to readable item,
// then add to list
data = (LPSTR)databuf;
valdata = data.GetBuffer(data.GetLength());
// Send name of keys to list
refCtrl.SetItem(dwCnt, 2, LVIF_TEXT,
(LPCTSTR)valname, NULL,
LVIS_SELECTED, -1, NULL);
refCtrl.SetItem(dwCnt, 3, LVIF_TEXT,
(LPCTSTR)valdata, NULL,
LVIS_SELECTED, -1, NULL);
refCtrl.UpdateWindow();
// End list items
}
}
//Enum here ???
while (cnt > 0)
{
cnt--;
char * sub = "";
lstrcat(sub, "\\");
lstrcat(sub, subbuf);
subbuf = sub;
EnumReg(hKeyResult, subbuf);
}
}
}
RegCloseKey(hKeyResult);