[REGEDIT]

- Use COUNT_OF where appropriate. Miscellaneous code cleanup. Patch by Hermès Bélusca
See issue #7182 for more details.

svn path=/trunk/; revision=56876
This commit is contained in:
Thomas Faber 2012-07-12 19:10:48 +00:00
parent 5cdab9e546
commit 42e6e0b684
12 changed files with 78 additions and 78 deletions

View file

@ -24,6 +24,6 @@
void ShowAboutBox(HWND hWnd)
{
TCHAR AppStr[255];
LoadString(hInst, IDS_APP_TITLE, AppStr, sizeof(AppStr)/sizeof(TCHAR));
LoadString(hInst, IDS_APP_TITLE, AppStr, COUNT_OF(AppStr));
ShellAbout(hWnd, AppStr, _T(""), LoadIcon(hInst, MAKEINTRESOURCE(IDI_REGEDIT)));
}

View file

@ -292,7 +292,7 @@ LRESULT CALLBACK AddressBarProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPar
case WM_KEYUP:
if (wParam == VK_RETURN)
{
GetWindowText(hwnd, s_szNode, sizeof(s_szNode) / sizeof(s_szNode[0]));
GetWindowText(hwnd, s_szNode, COUNT_OF(s_szNode));
SelectNode(g_pChildWnd->hTreeWnd, s_szNode);
}
break;
@ -325,7 +325,7 @@ LRESULT CALLBACK ChildWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa
HFONT hFont;
TCHAR buffer[MAX_PATH];
/* load "My Computer" string */
LoadString(hInst, IDS_MY_COMPUTER, buffer, sizeof(buffer)/sizeof(TCHAR));
LoadString(hInst, IDS_MY_COMPUTER, buffer, COUNT_OF(buffer));
g_pChildWnd = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(ChildWnd));
if (!g_pChildWnd) return 0;
@ -557,7 +557,7 @@ LRESULT CALLBACK ChildWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa
if (ptvdi->item.pszText)
{
keyPath = GetItemPath(g_pChildWnd->hTreeWnd, TreeView_GetParent(g_pChildWnd->hTreeWnd, ptvdi->item.hItem), &hRootKey);
_sntprintf(szBuffer, sizeof(szBuffer) / sizeof(szBuffer[0]), _T("%s\\%s"), keyPath, ptvdi->item.pszText);
_sntprintf(szBuffer, COUNT_OF(szBuffer), _T("%s\\%s"), keyPath, ptvdi->item.pszText);
keyPath = GetItemPath(g_pChildWnd->hTreeWnd, ptvdi->item.hItem, &hRootKey);
if (RegOpenKeyEx(hRootKey, szBuffer, 0, KEY_READ, &hKey) == ERROR_SUCCESS)
{
@ -693,7 +693,7 @@ LRESULT CALLBACK ChildWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa
(void)TreeView_GetItem(g_pChildWnd->hTreeWnd, &item);
/* Set the Expand/Collapse menu item appropriately */
LoadString(hInst, (item.state & TVIS_EXPANDED) ? IDS_COLLAPSE : IDS_EXPAND, buffer, sizeof(buffer) / sizeof(buffer[0]));
LoadString(hInst, (item.state & TVIS_EXPANDED) ? IDS_COLLAPSE : IDS_EXPAND, buffer, COUNT_OF(buffer));
memset(&mii, 0, sizeof(mii));
mii.cbSize = sizeof(mii);
mii.fMask = MIIM_STRING | MIIM_STATE | MIIM_ID;
@ -720,18 +720,18 @@ LRESULT CALLBACK ChildWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa
/* Come up with suggestions */
keyPath = GetItemPath(g_pChildWnd->hTreeWnd, NULL, &hRootKey);
SuggestKeys(hRootKey, keyPath, Suggestions, sizeof(Suggestions) / sizeof(Suggestions[0]));
SuggestKeys(hRootKey, keyPath, Suggestions, COUNT_OF(Suggestions));
if (Suggestions[0])
{
AppendMenu(hContextMenu, MF_SEPARATOR, 0, NULL);
LoadString(hInst, IDS_GOTO_SUGGESTED_KEY, resource, sizeof(resource) / sizeof(resource[0]));
LoadString(hInst, IDS_GOTO_SUGGESTED_KEY, resource, COUNT_OF(resource));
s = Suggestions;
wID = ID_TREE_SUGGESTION_MIN;
while(*s && (wID <= ID_TREE_SUGGESTION_MAX))
{
_sntprintf(buffer, sizeof(buffer) / sizeof(buffer[0]), resource, s);
_sntprintf(buffer, COUNT_OF(buffer), resource, s);
memset(&mii, 0, sizeof(mii));
mii.cbSize = sizeof(mii);

View file

@ -108,7 +108,7 @@ INT_PTR CALLBACK modify_string_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam, L
else
{
TCHAR buffer[255];
LoadString(hInst, IDS_DEFAULT_VALUE_NAME, buffer, sizeof(buffer)/sizeof(TCHAR));
LoadString(hInst, IDS_DEFAULT_VALUE_NAME, buffer, COUNT_OF(buffer));
SetDlgItemText(hwndDlg, IDC_VALUE_NAME, buffer);
}
SetDlgItemText(hwndDlg, IDC_VALUE_DATA, stringValueData);
@ -176,7 +176,7 @@ INT_PTR CALLBACK modify_multi_string_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wPa
else
{
TCHAR buffer[255];
LoadString(hInst, IDS_DEFAULT_VALUE_NAME, buffer, sizeof(buffer)/sizeof(TCHAR));
LoadString(hInst, IDS_DEFAULT_VALUE_NAME, buffer, COUNT_OF(buffer));
SetDlgItemText(hwndDlg, IDC_VALUE_NAME, buffer);
}
SetDlgItemText(hwndDlg, IDC_VALUE_DATA, stringValueData);
@ -296,7 +296,7 @@ INT_PTR CALLBACK modify_dword_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LP
else
{
TCHAR buffer[255];
LoadString(hInst, IDS_DEFAULT_VALUE_NAME, buffer, sizeof(buffer)/sizeof(TCHAR));
LoadString(hInst, IDS_DEFAULT_VALUE_NAME, buffer, COUNT_OF(buffer));
SetDlgItemText(hwndDlg, IDC_VALUE_NAME, buffer);
}
CheckRadioButton (hwndDlg, IDC_FORMAT_HEX, IDC_FORMAT_DEC, IDC_FORMAT_HEX);
@ -397,7 +397,7 @@ INT_PTR CALLBACK modify_binary_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam, L
else
{
TCHAR buffer[255];
LoadString(hInst, IDS_DEFAULT_VALUE_NAME, buffer, sizeof(buffer)/sizeof(TCHAR));
LoadString(hInst, IDS_DEFAULT_VALUE_NAME, buffer, COUNT_OF(buffer));
SetDlgItemText(hwndDlg, IDC_VALUE_NAME, buffer);
}
hwndValue = GetDlgItem(hwndDlg, IDC_VALUE_DATA);
@ -451,13 +451,13 @@ static BOOL CreateResourceColumns(HWND hwnd)
/* Load the column labels from the resource file. */
lvC.iSubItem = 0;
lvC.cx = (rc.right - rc.left) / 2;
LoadString(hInst, IDS_DMA_CHANNEL, szText, sizeof(szText)/sizeof(TCHAR));
LoadString(hInst, IDS_DMA_CHANNEL, szText, COUNT_OF(szText));
if (ListView_InsertColumn(hwndLV, 0, &lvC) == -1)
return FALSE;
lvC.iSubItem = 1;
lvC.cx = (rc.right - rc.left) - lvC.cx;
LoadString(hInst, IDS_DMA_PORT, szText, sizeof(szText)/sizeof(TCHAR));
LoadString(hInst, IDS_DMA_PORT, szText, COUNT_OF(szText));
if (ListView_InsertColumn(hwndLV, 1, &lvC) == -1)
return FALSE;
@ -471,23 +471,23 @@ static BOOL CreateResourceColumns(HWND hwnd)
/* Load the column labels from the resource file. */
lvC.iSubItem = 0;
lvC.cx = width;
LoadString(hInst, IDS_INTERRUPT_VECTOR, szText, sizeof(szText)/sizeof(TCHAR));
LoadString(hInst, IDS_INTERRUPT_VECTOR, szText, COUNT_OF(szText));
if (ListView_InsertColumn(hwndLV, 0, &lvC) == -1)
return FALSE;
lvC.iSubItem = 1;
LoadString(hInst, IDS_INTERRUPT_LEVEL, szText, sizeof(szText)/sizeof(TCHAR));
LoadString(hInst, IDS_INTERRUPT_LEVEL, szText, COUNT_OF(szText));
if (ListView_InsertColumn(hwndLV, 1, &lvC) == -1)
return FALSE;
lvC.iSubItem = 2;
LoadString(hInst, IDS_INTERRUPT_AFFINITY, szText, sizeof(szText)/sizeof(TCHAR));
LoadString(hInst, IDS_INTERRUPT_AFFINITY, szText, COUNT_OF(szText));
if (ListView_InsertColumn(hwndLV, 2, &lvC) == -1)
return FALSE;
lvC.iSubItem = 3;
lvC.cx = (rc.right - rc.left) - 3 * width;
LoadString(hInst, IDS_INTERRUPT_TYPE, szText, sizeof(szText)/sizeof(TCHAR));
LoadString(hInst, IDS_INTERRUPT_TYPE, szText, COUNT_OF(szText));
if (ListView_InsertColumn(hwndLV, 3, &lvC) == -1)
return FALSE;
@ -501,18 +501,18 @@ static BOOL CreateResourceColumns(HWND hwnd)
/* Load the column labels from the resource file. */
lvC.iSubItem = 0;
lvC.cx = width;
LoadString(hInst, IDS_MEMORY_ADDRESS, szText, sizeof(szText)/sizeof(TCHAR));
LoadString(hInst, IDS_MEMORY_ADDRESS, szText, COUNT_OF(szText));
if (ListView_InsertColumn(hwndLV, 0, &lvC) == -1)
return FALSE;
lvC.iSubItem = 1;
LoadString(hInst, IDS_MEMORY_LENGTH, szText, sizeof(szText)/sizeof(TCHAR));
LoadString(hInst, IDS_MEMORY_LENGTH, szText, COUNT_OF(szText));
if (ListView_InsertColumn(hwndLV, 1, &lvC) == -1)
return FALSE;
lvC.iSubItem = 2;
lvC.cx = (rc.right - rc.left) - 2 * width;
LoadString(hInst, IDS_MEMORY_ACCESS, szText, sizeof(szText)/sizeof(TCHAR));
LoadString(hInst, IDS_MEMORY_ACCESS, szText, COUNT_OF(szText));
if (ListView_InsertColumn(hwndLV, 2, &lvC) == -1)
return FALSE;
@ -526,18 +526,18 @@ static BOOL CreateResourceColumns(HWND hwnd)
/* Load the column labels from the resource file. */
lvC.iSubItem = 0;
lvC.cx = width;
LoadString(hInst, IDS_PORT_ADDRESS, szText, sizeof(szText)/sizeof(TCHAR));
LoadString(hInst, IDS_PORT_ADDRESS, szText, COUNT_OF(szText));
if (ListView_InsertColumn(hwndLV, 0, &lvC) == -1)
return FALSE;
lvC.iSubItem = 1;
LoadString(hInst, IDS_PORT_LENGTH, szText, sizeof(szText)/sizeof(TCHAR));
LoadString(hInst, IDS_PORT_LENGTH, szText, COUNT_OF(szText));
if (ListView_InsertColumn(hwndLV, 1, &lvC) == -1)
return FALSE;
lvC.iSubItem = 2;
lvC.cx = (rc.right - rc.left) - 2 * width;
LoadString(hInst, IDS_PORT_ACCESS, szText, sizeof(szText)/sizeof(TCHAR));
LoadString(hInst, IDS_PORT_ACCESS, szText, COUNT_OF(szText));
if (ListView_InsertColumn(hwndLV, 2, &lvC) == -1)
return FALSE;
@ -550,18 +550,18 @@ static BOOL CreateResourceColumns(HWND hwnd)
/* Load the column labels from the resource file. */
lvC.iSubItem = 0;
lvC.cx = width;
LoadString(hInst, IDS_SPECIFIC_RESERVED1, szText, sizeof(szText)/sizeof(TCHAR));
LoadString(hInst, IDS_SPECIFIC_RESERVED1, szText, COUNT_OF(szText));
if (ListView_InsertColumn(hwndLV, 0, &lvC) == -1)
return FALSE;
lvC.iSubItem = 1;
LoadString(hInst, IDS_SPECIFIC_RESERVED2, szText, sizeof(szText)/sizeof(TCHAR));
LoadString(hInst, IDS_SPECIFIC_RESERVED2, szText, COUNT_OF(szText));
if (ListView_InsertColumn(hwndLV, 1, &lvC) == -1)
return FALSE;
lvC.iSubItem = 2;
lvC.cx = (rc.right - rc.left) - 2 * width;
LoadString(hInst, IDS_SPECIFIC_DATASIZE, szText, sizeof(szText)/sizeof(TCHAR));
LoadString(hInst, IDS_SPECIFIC_DATASIZE, szText, COUNT_OF(szText));
if (ListView_InsertColumn(hwndLV, 2, &lvC) == -1)
return FALSE;
@ -715,9 +715,9 @@ ParseResources(HWND hwnd)
ListView_SetItemText(hwndLV, iItem, 1, buffer);
if (pDescriptor->Flags & CM_RESOURCE_PORT_IO)
LoadString(hInst, IDS_PORT_PORT_IO, buffer, sizeof(buffer)/sizeof(TCHAR));
LoadString(hInst, IDS_PORT_PORT_IO, buffer, COUNT_OF(buffer));
else
LoadString(hInst, IDS_PORT_MEMORY_IO, buffer, sizeof(buffer)/sizeof(TCHAR));
LoadString(hInst, IDS_PORT_MEMORY_IO, buffer, COUNT_OF(buffer));
ListView_SetItemText(hwndLV, iItem, 2, buffer);
}
break;
@ -746,9 +746,9 @@ ParseResources(HWND hwnd)
ListView_SetItemText(hwndLV, iItem, 2, buffer);
if (pDescriptor->Flags & CM_RESOURCE_INTERRUPT_LATCHED)
LoadString(hInst, IDS_INTERRUPT_EDGE_SENSITIVE, buffer, sizeof(buffer)/sizeof(TCHAR));
LoadString(hInst, IDS_INTERRUPT_EDGE_SENSITIVE, buffer, COUNT_OF(buffer));
else
LoadString(hInst, IDS_INTERRUPT_LEVEL_SENSITIVE, buffer, sizeof(buffer)/sizeof(TCHAR));
LoadString(hInst, IDS_INTERRUPT_LEVEL_SENSITIVE, buffer, COUNT_OF(buffer));
ListView_SetItemText(hwndLV, iItem, 3, buffer);
}
@ -781,15 +781,15 @@ ParseResources(HWND hwnd)
switch (pDescriptor->Flags & (CM_RESOURCE_MEMORY_READ_ONLY | CM_RESOURCE_MEMORY_WRITE_ONLY))
{
case CM_RESOURCE_MEMORY_READ_ONLY:
LoadString(hInst, IDS_MEMORY_READ_ONLY, buffer, sizeof(buffer)/sizeof(TCHAR));
LoadString(hInst, IDS_MEMORY_READ_ONLY, buffer, COUNT_OF(buffer));
break;
case CM_RESOURCE_MEMORY_WRITE_ONLY:
LoadString(hInst, IDS_MEMORY_WRITE_ONLY, buffer, sizeof(buffer)/sizeof(TCHAR));
LoadString(hInst, IDS_MEMORY_WRITE_ONLY, buffer, COUNT_OF(buffer));
break;
default:
LoadString(hInst, IDS_MEMORY_READ_WRITE, buffer, sizeof(buffer)/sizeof(TCHAR));
LoadString(hInst, IDS_MEMORY_READ_WRITE, buffer, COUNT_OF(buffer));
break;
}
@ -951,13 +951,13 @@ static BOOL CreateResourceListColumns(HWND hWndListView)
/* Load the column labels from the resource file. */
lvC.iSubItem = 0;
lvC.cx = (rc.right - rc.left) / 2;
LoadString(hInst, IDS_BUSNUMBER, szText, sizeof(szText)/sizeof(TCHAR));
LoadString(hInst, IDS_BUSNUMBER, szText, COUNT_OF(szText));
if (ListView_InsertColumn(hWndListView, 0, &lvC) == -1)
return FALSE;
lvC.iSubItem = 1;
lvC.cx = (rc.right - rc.left) - lvC.cx;
LoadString(hInst, IDS_INTERFACE, szText, sizeof(szText)/sizeof(TCHAR));
LoadString(hInst, IDS_INTERFACE, szText, COUNT_OF(szText));
if (ListView_InsertColumn(hWndListView, 1, &lvC) == -1)
return FALSE;
@ -1456,8 +1456,8 @@ BOOL DeleteKey(HWND hwnd, HKEY hKeyRoot, LPCTSTR keyPath)
return FALSE;
}
LoadString(hInst, IDS_QUERY_DELETE_KEY_CONFIRM, caption, sizeof(caption)/sizeof(TCHAR));
LoadString(hInst, IDS_QUERY_DELETE_KEY_ONE, msg, sizeof(msg)/sizeof(TCHAR));
LoadString(hInst, IDS_QUERY_DELETE_KEY_CONFIRM, caption, COUNT_OF(caption));
LoadString(hInst, IDS_QUERY_DELETE_KEY_ONE, msg, COUNT_OF(msg));
if (MessageBox(g_pChildWnd->hWnd, msg, caption, MB_ICONQUESTION | MB_YESNO) != IDYES)
goto done;

View file

@ -774,7 +774,7 @@ static INT_PTR CALLBACK FindDialogProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPAR
hControl = GetDlgItem(hDlg, IDC_FINDWHAT);
if (hControl)
GetWindowText(hControl, s_szFindWhat, sizeof(s_szFindWhat) / sizeof(s_szFindWhat[0]));
GetWindowText(hControl, s_szFindWhat, COUNT_OF(s_szFindWhat));
EndDialog(hDlg, 1);
break;
@ -788,7 +788,7 @@ static INT_PTR CALLBACK FindDialogProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPAR
switch(LOWORD(wParam))
{
case IDC_FINDWHAT:
GetWindowText((HWND) lParam, s_szSavedFindValue, sizeof(s_szSavedFindValue) / sizeof(s_szSavedFindValue[0]));
GetWindowText((HWND) lParam, s_szSavedFindValue, COUNT_OF(s_szSavedFindValue));
hControl = GetDlgItem(hDlg, IDOK);
if (hControl)
{
@ -817,8 +817,8 @@ void FindDialog(HWND hWnd)
{
TCHAR msg[128], caption[128];
LoadString(hInst, IDS_FINISHEDFIND, msg, sizeof(msg)/sizeof(TCHAR));
LoadString(hInst, IDS_APP_TITLE, caption, sizeof(caption)/sizeof(TCHAR));
LoadString(hInst, IDS_FINISHEDFIND, msg, COUNT_OF(msg));
LoadString(hInst, IDS_APP_TITLE, caption, COUNT_OF(caption));
MessageBox(0, msg, caption, MB_ICONINFORMATION);
}
}

View file

@ -924,7 +924,7 @@ InitializeRemoteRegistryPicker(OUT IDsObjectPicker **pDsObjectPicker)
InitInfo.cbSize = sizeof(InitInfo);
InitInfo.pwzTargetComputer = NULL;
InitInfo.cDsScopeInfos = sizeof(Scopes) / sizeof(Scopes[0]);
InitInfo.cDsScopeInfos = COUNT_OF(Scopes);
InitInfo.aDsScopeInfos = Scopes;
InitInfo.flOptions = 0;
InitInfo.cAttributesToFetch = 0;
@ -1065,7 +1065,7 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
hRet = InvokeRemoteRegistryPickerDialog(ObjectPicker,
hWnd,
szComputerName,
sizeof(szComputerName) / sizeof(szComputerName[0]));
COUNT_OF(szComputerName));
if (hRet == S_OK)
{
/* FIXME - connect to the registry */
@ -1269,7 +1269,7 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
mii.fMask = MIIM_TYPE;
mii.fType = MFT_STRING;
mii.dwTypeData = szFavorite;
mii.cch = sizeof(szFavorite) / sizeof(szFavorite[0]);
mii.cch = COUNT_OF(szFavorite);
if (GetMenuItemInfo(hMenu, LOWORD(wParam) - ID_FAVORITES_MIN, TRUE, &mii))
{

View file

@ -176,7 +176,7 @@ static void AddEntryToList(HWND hwndLV, LPTSTR Name, DWORD dwValType, void* ValB
{
TCHAR buffer[255];
/* load (value not set) string */
LoadString(hInst, IDS_VALUE_NOT_SET, buffer, sizeof(buffer)/sizeof(TCHAR));
LoadString(hInst, IDS_VALUE_NOT_SET, buffer, COUNT_OF(buffer));
ListView_SetItemText(hwndLV, index, 2, buffer);
}
break;
@ -216,7 +216,7 @@ static void AddEntryToList(HWND hwndLV, LPTSTR Name, DWORD dwValType, void* ValB
}
else
{
LoadString(hInst, IDS_INVALID_DWORD, buf, sizeof(buf)/sizeof(TCHAR));
LoadString(hInst, IDS_INVALID_DWORD, buf, COUNT_OF(buf));
}
ListView_SetItemText(hwndLV, index, 2, buf);
}
@ -241,7 +241,7 @@ static void AddEntryToList(HWND hwndLV, LPTSTR Name, DWORD dwValType, void* ValB
else
{
TCHAR szText[128];
LoadString(hInst, IDS_BINARY_EMPTY, szText, sizeof(szText)/sizeof(TCHAR));
LoadString(hInst, IDS_BINARY_EMPTY, szText, COUNT_OF(szText));
ListView_SetItemText(hwndLV, index, 2, szText);
}
}
@ -266,7 +266,7 @@ static BOOL CreateListColumns(HWND hWndListView)
lvC.iSubItem = index;
lvC.cx = default_column_widths[index];
lvC.fmt = column_alignment[index];
LoadString(hInst, IDS_LIST_COLUMN_FIRST + index, szText, sizeof(szText)/sizeof(TCHAR));
LoadString(hInst, IDS_LIST_COLUMN_FIRST + index, szText, COUNT_OF(szText));
if (ListView_InsertColumn(hWndListView, index, &lvC) == -1) return FALSE;
}
return TRUE;
@ -313,7 +313,7 @@ static void OnGetDispInfo(NMLVDISPINFO* plvdi)
switch (plvdi->item.iSubItem)
{
case 0:
LoadString(hInst, IDS_DEFAULT_VALUE_NAME, buffer, sizeof(buffer)/sizeof(TCHAR));
LoadString(hInst, IDS_DEFAULT_VALUE_NAME, buffer, COUNT_OF(buffer));
plvdi->item.pszText = buffer;
break;
case 1:
@ -358,7 +358,7 @@ static void OnGetDispInfo(NMLVDISPINFO* plvdi)
default:
{
TCHAR buf2[200];
LoadString(hInst, IDS_UNKNOWN_TYPE, buf2, sizeof(buf2)/sizeof(TCHAR));
LoadString(hInst, IDS_UNKNOWN_TYPE, buf2, COUNT_OF(buf2));
wsprintf(buffer, buf2, ((LINE_INFO*)plvdi->item.lParam)->dwValType);
plvdi->item.pszText = buffer;
break;
@ -453,8 +453,8 @@ BOOL ListWndNotifyProc(HWND hWnd, WPARAM wParam, LPARAM lParam, BOOL *Result)
{
TCHAR msg[128], caption[128];
LoadString(hInst, IDS_ERR_RENVAL_TOEMPTY, msg, sizeof(msg)/sizeof(TCHAR));
LoadString(hInst, IDS_ERR_RENVAL_CAPTION, caption, sizeof(caption)/sizeof(TCHAR));
LoadString(hInst, IDS_ERR_RENVAL_TOEMPTY, msg, COUNT_OF(msg));
LoadString(hInst, IDS_ERR_RENVAL_CAPTION, caption, COUNT_OF(caption));
MessageBox(0, msg, caption, 0);
*Result = TRUE;
}

View file

@ -82,10 +82,11 @@ BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
wcChild.cbWndExtra = sizeof(HANDLE);
wcChild.hInstance = hInstance;
wcChild.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_REGEDIT));
wcChild.hCursor = LoadCursor(0, IDC_ARROW),
wcChild.lpszClassName = szChildClass,
wcChild.hIconSm = (HICON)LoadImage(hInstance, MAKEINTRESOURCE(IDI_REGEDIT), IMAGE_ICON,
GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_SHARED);
wcChild.hCursor = LoadCursor(0, IDC_ARROW);
wcChild.lpszClassName = szChildClass;
wcChild.hIconSm = (HICON)LoadImage(hInstance, MAKEINTRESOURCE(IDI_REGEDIT),
IMAGE_ICON, GetSystemMetrics(SM_CXSMICON),
GetSystemMetrics(SM_CYSMICON), LR_SHARED);
RegisterClassEx(&wcChild); /* register child windows class */

View file

@ -108,7 +108,7 @@ void get_file_name(LPWSTR *command_line, LPWSTR file_name)
pos++;
}
}
memcpy(file_name, *command_line, pos * sizeof((*command_line)[0]));
memcpy(file_name, *command_line, pos * sizeof(WCHAR));
/* remove the last backslash */
if (file_name[pos - 1] == L'\\')
{
@ -163,8 +163,8 @@ BOOL PerformRegAction(REGEDIT_ACTION action, LPWSTR s, BOOL silent)
}
import_registry_file(fp);
get_file_name(&s, filename);
LoadString(hInst, IDS_APP_TITLE, szTitle, sizeof(szTitle));
LoadString(hInst, IDS_IMPORTED_OK, szText, sizeof(szTitle));
LoadString(hInst, IDS_APP_TITLE, szTitle, COUNT_OF(szTitle));
LoadString(hInst, IDS_IMPORTED_OK, szText, COUNT_OF(szText));
/* show successful import */
if (!silent)
MessageBox(NULL, szText, szTitle, MB_OK);
@ -322,18 +322,17 @@ BOOL ProcessCmdLine(LPWSTR lpCmdLine)
}
if (*s && action == ACTION_UNDEF)
{
TCHAR szTitle[256], szText[256];
LoadString(hInst, IDS_APP_TITLE, szTitle, sizeof(szTitle));
LoadString(hInst, IDS_IMPORT_PROMPT, szText, sizeof(szTitle));
/* request import confirmation */
if (silent || MessageBox(NULL, szText, szTitle, MB_YESNO) == IDYES)
{
action = ACTION_ADD;
}
else return TRUE;
}
if (action == ACTION_UNDEF)
{
TCHAR szTitle[256], szText[256];
LoadString(hInst, IDS_APP_TITLE, szTitle, COUNT_OF(szTitle));
LoadString(hInst, IDS_IMPORT_PROMPT, szText, COUNT_OF(szText));
/* request import confirmation */
if (silent || MessageBox(NULL, szText, szTitle, MB_YESNO) == IDYES)
action = ACTION_ADD;
else
return TRUE;
}
if (action == ACTION_UNDEF)
return FALSE;
return PerformRegAction(action, s, silent);

View file

@ -36,7 +36,7 @@ static const CHAR *reg_class_names[] =
"HKEY_CURRENT_CONFIG", "HKEY_CURRENT_USER", "HKEY_DYN_DATA"
};
#define REG_CLASS_NUMBER (sizeof(reg_class_names) / sizeof(reg_class_names[0]))
#define REG_CLASS_NUMBER (COUNT_OF(reg_class_names))
const WCHAR* reg_class_namesW[REG_CLASS_NUMBER] =
{

View file

@ -447,7 +447,7 @@ ISecurityInformation_fnGetAccessRights(struct ISecurityInformation *this,
ULONG* piDefaultAccess)
{
*ppAccess = RegAccess;
*pcAccesses = sizeof(RegAccess) / sizeof(RegAccess[0]);
*pcAccesses = COUNT_OF(RegAccess);
*piDefaultAccess = RegDefaultAccess;
return S_OK;
}
@ -475,7 +475,7 @@ ISecurityInformation_fnGetInheritTypes(struct ISecurityInformation *this,
if (obj->ObjectInfo.dwFlags & SI_CONTAINER)
{
*ppInheritTypes = RegInheritTypes;
*pcInheritTypes = sizeof(RegInheritTypes) / sizeof(RegInheritTypes[0]);
*pcInheritTypes = COUNT_OF(RegInheritTypes);
return S_OK;
}

View file

@ -128,7 +128,7 @@ extern void SaveSettings(void)
if (keyPath)
{
rootName = get_root_key_name(hRootKey);
_sntprintf(szBuffer, sizeof(szBuffer) / sizeof(szBuffer[0]), _T("My Computer\\%s\\%s"), rootName, keyPath);
_sntprintf(szBuffer, COUNT_OF(szBuffer), _T("My Computer\\%s\\%s"), rootName, keyPath);
RegSetValueEx(hKey, _T("LastKey"), 0, REG_SZ, (LPBYTE) szBuffer, (DWORD) _tcslen(szBuffer) * sizeof(szBuffer[0]));
}

View file

@ -586,7 +586,7 @@ BOOL CreateNewKey(HWND hwndTV, HTREEITEM hItem)
else if (RegOpenKey(hRootKey, pszKeyPath, &hKey) != ERROR_SUCCESS)
goto done;
if (LoadString(hInst, IDS_NEW_KEY, szNewKeyFormat, sizeof(szNewKeyFormat) / sizeof(szNewKeyFormat[0])) <= 0)
if (LoadString(hInst, IDS_NEW_KEY, szNewKeyFormat, COUNT_OF(szNewKeyFormat)) <= 0)
goto done;
/* Need to create a new key with a unique name */
@ -704,7 +704,7 @@ BOOL SelectNode(HWND hwndTV, LPCTSTR keyPath)
tvi.hItem = hChildItem;
tvi.mask = TVIF_TEXT | TVIF_CHILDREN;
tvi.pszText = szBuffer;
tvi.cchTextMax = sizeof(szBuffer) / sizeof(szBuffer[0]);
tvi.cchTextMax = COUNT_OF(szBuffer);
(void)TreeView_GetItem(hwndTV, &tvi);