Karavaev Denis wrote:
how do you think, if I'll be on this forum if I can't create a dialog box?
Well, you *did* say Unfortunly, I know C++ to bad to compile it myself.. You'd be amazed at some of the questions we get around here. Most are intelligent but some are just out of control.
C1004 means you either didn't put a final bracket, or you didn't include stdafx.h. The missing bracket is at the end. The HANDLE parameter should be a HKEY. Where the code checks if retValue == ERROR_SUCCESS, it should check for != ERROR_NO_MORE_ITEMS. Where it passes in MAX_PATH to RegEnumValues, it should set a DWORD to = MAX_PATH, pass in a pointer to that variable, and reset the variable to MAX_PATH. I think that was all, but my code follows to make sure. This smaple is SCREWED.
#define MAX_VALUE_NAME 255
VOID QueryKey(HWND hDlg, HKEY hKey)
{
CHAR achKey[MAX_PATH];
CHAR achClass[MAX_PATH] = "";
DWORD cchClassName = MAX_PATH;
DWORD cSubKeys;
DWORD cbMaxSubKey;
DWORD cchMaxClass;
DWORD cValues;
DWORD cchMaxValue;
DWORD cbMaxValueData;
DWORD cbSecurityDescriptor;
FILETIME ftLastWriteTime;
DWORD i, j;
DWORD retCode, retValue;
CHAR achValue[MAX_VALUE_NAME];
DWORD cchValue = MAX_VALUE_NAME;
CHAR achBuff[80];
RegQueryInfoKey(hKey,
achClass,
&cchClassName,
NULL,
&cSubKeys,
&cbMaxSubKey,
&cchMaxClass,
&cValues,
&cchMaxValue,
&cbMaxValueData,
&cbSecurityDescriptor,
&ftLastWriteTime);
SendMessage(GetDlgItem(hDlg, IDL_LISTBOX),
LB_ADDSTRING, 0, (LONG) "..");
DWORD dwLength = MAX_PATH;
SetCursor(LoadCursor(NULL, IDC_WAIT));
for (i = 0, retCode = ERROR_SUCCESS;
retCode != ERROR_NO_MORE_ITEMS; i++)
{
retCode = RegEnumKeyEx(hKey,
i,
achKey,
&dwLength,
NULL,
NULL,
NULL,
&ftLastWriteTime);
if (retCode != (DWORD)ERROR_NO_MORE_ITEMS)
{
SendMessage(GetDlgItem(hDlg, IDL_LISTBOX),
LB_ADDSTRING, 0, (LONG) achKey);
}
dwLength = MAX_PATH;
}
SetCursor(LoadCursor (NULL, IDC_ARROW));
SetCursor(LoadCursor(NULL, IDC_WAIT));
if (cValues)
{
for (j = 0, retValue = ERROR_SUCCESS;
j < cValues; j++)
{
cchValue = MAX_VALUE_NAME;
achValue[0] = '\0';
retValue = RegEnumValue(hKey, j, achValue,
&cchValue,
NULL,
NULL,
NULL,
NULL);
if (retValue != (DWORD) ERROR_SUCCESS &&
retValue != ERROR_INSUFFICIENT_BUFFER)
{
wsprintf (achBuff,
"Line:%d 0 based index = %d, retValue = %d, "
"ValueLen = %d",
__LINE__, j, retValue, cchValue);
MessageBox (hDlg, achBuff, "Debug", MB_OK);
}
achBuff[0] = '\0';
if (!lstrlen(achValue))
lstrcpy(achValue, "<NO NAME>");
wsprintf(achBuff, "%d) %s ", j, achValue);
SendMessage(GetDlgItem(hDlg,IDL_LISTBOX2),
LB_ADDSTRING, 0, (LONG) achBuff);
}
}
SetCursor(LoadCursor(NULL, IDC_ARROW));
}
and in OnPaint:
CDialog::OnPaint();
HKEY key;
DWORD result;
RegCreateKeyEx(HKEY_CURRENT_USER, _T("Software"), NULL,
NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &key, &result);
ASSERT(REG_OPENED_EXISTING_KEY == result);
QueryKey(m_hWnd, key);
RegCloseKey(key);
Christian
After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001
Sonork ID 100.10002:MeanManOzI live in Bob's HungOut now
|