Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
Zezula Ladislav committed Nov 1, 2019
1 parent e57043a commit a29b9b0
Show file tree
Hide file tree
Showing 17 changed files with 63 additions and 63 deletions.
10 changes: 5 additions & 5 deletions DateTime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ static WORD LocaleNameToNumber(LPCTSTR szStr, LCID lcMin, LCID lcMax, LCID lcExt
for(lcid = lcMax; lcid >= lcMin; lcid--)
{
// Get the localized month name
nLength = GetLocaleInfo(LOCALE_USER_DEFAULT, lcid, szLocaleName, _maxchars(szLocaleName));
nLength = GetLocaleInfo(LOCALE_USER_DEFAULT, lcid, szLocaleName, _countof(szLocaleName));
if(nLength == 0)
break;

Expand All @@ -98,7 +98,7 @@ static WORD LocaleNameToNumber(LPCTSTR szStr, LCID lcMin, LCID lcMax, LCID lcExt
if(lcExtra != 0)
{
// Get the localized 13th month name
nLength = GetLocaleInfo(LOCALE_USER_DEFAULT, lcExtra, szLocaleName, _maxchars(szLocaleName));
nLength = GetLocaleInfo(LOCALE_USER_DEFAULT, lcExtra, szLocaleName, _countof(szLocaleName));
if(nLength > 1)
{
// If the month name is identical, we found it
Expand Down Expand Up @@ -132,7 +132,7 @@ static WORD MonthNameGenitiveToNumber(LPCTSTR szStr, int * piMonthNameLength)
for(stTemp.wMonth = 1; stTemp.wMonth <= 13; stTemp.wMonth++)
{
// Get genitive of month name
nLength = GetDateFormat(LOCALE_USER_DEFAULT, 0, &stTemp, _T("ddMMMM"), szMonthName, _maxchars(szMonthName));
nLength = GetDateFormat(LOCALE_USER_DEFAULT, 0, &stTemp, _T("ddMMMM"), szMonthName, _countof(szMonthName));
if(nLength < 3)
break;

Expand All @@ -155,7 +155,7 @@ static BOOL AmPmNameToWord(LPCTSTR szStr, WORD & wHourModifier, int & nAmPmNameL
int nLength;

// Check AM
nLength = GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_S1159, szAmPmStr, _maxchars(szAmPmStr));
nLength = GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_S1159, szAmPmStr, _countof(szAmPmStr));
if(nLength > 0 && szStr[0] == szAmPmStr[0])
{
nAmPmNameLength = nLength;
Expand All @@ -164,7 +164,7 @@ static BOOL AmPmNameToWord(LPCTSTR szStr, WORD & wHourModifier, int & nAmPmNameL
}

// Check PM
nLength = GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_S2359, szAmPmStr, _maxchars(szAmPmStr));
nLength = GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_S2359, szAmPmStr, _countof(szAmPmStr));
if(nLength > 0 && szStr[0] == szAmPmStr[0])
{
nAmPmNameLength = nLength;
Expand Down
8 changes: 4 additions & 4 deletions DlgEasEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,15 +178,15 @@ void MoveItem(HWND hDlg, BOOL bUp)
lvi1.stateMask = (UINT)-1;
lvi1.iItem = nItem1;
lvi1.pszText = szText1;
lvi1.cchTextMax = _maxchars(szText1);
lvi1.cchTextMax = _countof(szText1);
ListView_GetItem(hListView, &lvi1);

ZeroMemory(&lvi2, sizeof(LVITEM));
lvi2.mask = LVIF_IMAGE | LVIF_STATE | LVIF_TEXT | LVIF_PARAM;
lvi2.stateMask = (UINT)-1;
lvi2.iItem = nItem2;
lvi2.pszText = szText2;
lvi2.cchTextMax = _maxchars(szText2);
lvi2.cchTextMax = _countof(szText2);
ListView_GetItem(hListView, &lvi2);

// Switch the main items
Expand All @@ -196,8 +196,8 @@ void MoveItem(HWND hDlg, BOOL bUp)
ListView_SetItem(hListView, &lvi1);

// Switch the texts for the subitems
ListView_GetItemText(hListView, nItem1, 1, szText1, _maxchars(szText1));
ListView_GetItemText(hListView, nItem2, 1, szText2, _maxchars(szText2));
ListView_GetItemText(hListView, nItem1, 1, szText1, _countof(szText1));
ListView_GetItemText(hListView, nItem2, 1, szText2, _countof(szText2));
ListView_SetItemText(hListView, nItem1, 1, szText2);
ListView_SetItemText(hListView, nItem2, 1, szText1);

Expand Down
6 changes: 3 additions & 3 deletions DlgFileTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ static void AlertApcThread(TWindowData * pData, DWORD dwAlertReason)
static void GetFileTestAppTitle(LPTSTR szTitle, int nMaxChars)
{
TCHAR szUserName[256] = _T("");
DWORD dwSize = _maxchars(szUserName);
DWORD dwSize = _countof(szUserName);
UINT nIDTitle = IDS_APP_TITLE;
BOOL bElevated = FALSE;

Expand All @@ -194,7 +194,7 @@ static void InitializeTabControl(HWND hDlg, TWindowData * pData)
int nPages = 0;

// Get the title of FileTest application
GetFileTestAppTitle(szAppTitle, _maxchars(szAppTitle));
GetFileTestAppTitle(szAppTitle, _countof(szAppTitle));

// Fill the property sheet header
ZeroMemory(&psh, sizeof(PROPSHEETHEADER));
Expand Down Expand Up @@ -514,7 +514,7 @@ static void AddAboutToSystemMenu(HWND hDlg)
// If we found a separator, we need to add two more items
if(nSeparatorIndex != -1)
{
LoadString(g_hInst, IDS_HELP_ABOUT, szItemText, _maxchars(szItemText));
LoadString(g_hInst, IDS_HELP_ABOUT, szItemText, _countof(szItemText));
InsertMenu(hSysMenu, nSeparatorIndex, MF_BYPOSITION | MF_SEPARATOR, 0, NULL);
InsertMenu(hSysMenu, nSeparatorIndex+1, MF_BYPOSITION | MF_STRING, SC_HELP_ABOUT, szItemText);
}
Expand Down
2 changes: 1 addition & 1 deletion DlgFlags.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ static void CreateDialogLayout_Empty(TFlagDialogData * pData)
// If there is at least one flag unused, we need to create an extra button
if(dwFlags != 0)
{
LoadString(g_hInst, IDS_CUSTOM_VALUE, pData->szCustomValue, _maxchars(pData->szCustomValue));
LoadString(g_hInst, IDS_CUSTOM_VALUE, pData->szCustomValue, _countof(pData->szCustomValue));
pData->ExtraFlag.dwValue = dwFlags;
pData->ExtraFlag.dwMask = 0xFFFFFFFF;
pData->ExtraFlag.szFlagText = pData->szCustomValue;
Expand Down
2 changes: 1 addition & 1 deletion DlgSimple.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ static void SetWindowModuleVersion(HWND hWndChild, LPCTSTR szModuleName)
// Is such window really there ?
if(hWndChild != NULL)
{
GetWindowText(hWndChild, szFormat, _maxchars(szFormat));
GetWindowText(hWndChild, szFormat, _countof(szFormat));
GetModuleVersion(szModuleName, &Version);
StringCchPrintf(szText, _countof(szText), szFormat,
HIWORD(Version.HighPart),
Expand Down
4 changes: 2 additions & 2 deletions FileTest.rc
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,13 @@ BEGIN
BEGIN
VALUE "CompanyName", "Ladislav Zezula"
VALUE "FileDescription", "Interactive File System API Test"
VALUE "FileVersion", "2, 7, 0, 595\0"
VALUE "FileVersion", "2, 7, 0, 595"
VALUE "InternalName", "FileTest"
VALUE "LegalCopyright", "Copyright � 2004 - 2018 Ladislav Zezula"
VALUE "LegalTrademarks", "http://www.zezula.net"
VALUE "OriginalFilename", "FileTest.exe"
VALUE "ProductName", "FileTest"
VALUE "ProductVersion", "2, 7, 0, 595\0"
VALUE "ProductVersion", "2, 7, 0, 595"
END
END
BLOCK "VarFileInfo"
Expand Down
6 changes: 3 additions & 3 deletions Page01Create.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ static int SaveDialog(HWND hDlg)
HWND hCombo = GetDlgItem(hDlg, IDC_CREATE_DISPOSITION);
int nError = ERROR_SUCCESS;

GetDlgItemText(hDlg, IDC_DIRECTORY_NAME, pData->szDirName, _maxchars(pData->szDirName));
GetDlgItemText(hDlg, IDC_FILE_NAME, pData->szFileName1, _maxchars(pData->szFileName1));
GetDlgItemText(hDlg, IDC_TEMPLATE_FILE, pData->szTemplate, _maxchars(pData->szTemplate));
GetDlgItemText(hDlg, IDC_DIRECTORY_NAME, pData->szDirName, _countof(pData->szDirName));
GetDlgItemText(hDlg, IDC_FILE_NAME, pData->szFileName1, _countof(pData->szFileName1));
GetDlgItemText(hDlg, IDC_TEMPLATE_FILE, pData->szTemplate, _countof(pData->szTemplate));

if((nError = DlgText2Hex32(hDlg, IDC_DESIRED_ACCESS, &pData->dwDesiredAccess)) != ERROR_SUCCESS)
return nError;
Expand Down
10 changes: 5 additions & 5 deletions Page02NtCreate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,8 @@ static int SaveDialog(HWND hDlg)
HWND hCombo = GetDlgItem(hDlg, IDC_CREATE_DISPOSITION);
int nError;

GetDlgItemText(hDlg, IDC_DIRECTORY_NAME, pData->szDirName, _maxchars(pData->szDirName));
GetDlgItemText(hDlg, IDC_FILE_NAME, pData->szFileName1, _maxchars(pData->szFileName1));
GetDlgItemText(hDlg, IDC_DIRECTORY_NAME, pData->szDirName, _countof(pData->szDirName));
GetDlgItemText(hDlg, IDC_FILE_NAME, pData->szFileName1, _countof(pData->szFileName1));

if((nError = DlgText2Hex32(hDlg, IDC_OBJ_ATTR_FLAGS, &pData->dwObjAttrFlags)) != ERROR_SUCCESS)
return nError;
Expand Down Expand Up @@ -320,7 +320,7 @@ static int OnSetActive(HWND hDlg)
Hex2DlgText32(hDlg, IDC_CREATE_OPTIONS, pData->dwCreateOptions);

// Update the info about extended attributes
rsprintf(szEaInfo, _maxchars(szEaInfo), IDS_EA_INFO, pData->pFileEa, pData->dwEaSize);
rsprintf(szEaInfo, _countof(szEaInfo), IDS_EA_INFO, pData->pFileEa, pData->dwEaSize);
SetDlgItemText(hDlg, IDC_EXTENDED_ATTRIBUTES, szEaInfo);

// Enable/disable transaction
Expand Down Expand Up @@ -357,7 +357,7 @@ static int OnRelativeFileHelp(HWND hDlg)
int nLength = 0;

// Load both parts of the message
nLength = LoadString(g_hInst, IDS_RELATIVE_FILE_HELP, szMsgFormat, _maxchars(szMsgFormat));
nLength = LoadString(g_hInst, IDS_RELATIVE_FILE_HELP, szMsgFormat, _countof(szMsgFormat));
if(nLength > 0)
{
// Allocate big buffer for the entire text
Expand Down Expand Up @@ -474,7 +474,7 @@ static int OnEditEaClick(HWND hDlg)
if(ExtendedAtributesEditorDialog(hDlg, pData) == IDOK)
{
// Update the info about extended attributes
rsprintf(szEaInfo, _maxchars(szEaInfo), IDS_EA_INFO, pData->pFileEa, pData->dwEaSize);
rsprintf(szEaInfo, _countof(szEaInfo), IDS_EA_INFO, pData->pFileEa, pData->dwEaSize);
SetDlgItemText(hDlg, IDC_EXTENDED_ATTRIBUTES, szEaInfo);
}

Expand Down
2 changes: 1 addition & 1 deletion Page04Mapping.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ static int SaveDialog1(HWND hDlg)
TFileTestData * pData = GetDialogData(hDlg);
int nError;

GetDlgItemText(hDlg, IDC_SECTION_NAME, pData->szSectionName, _maxchars(pData->szSectionName));
GetDlgItemText(hDlg, IDC_SECTION_NAME, pData->szSectionName, _countof(pData->szSectionName));

if((nError = DlgText2Hex64(hDlg, IDC_SECTION_SIZE, &pData->MaximumSize.QuadPart)) != ERROR_SUCCESS)
return nError;
Expand Down
12 changes: 6 additions & 6 deletions Page05FileOps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -565,8 +565,8 @@ static int SaveDialog(HWND hDlg)
TFileTestData * pData = GetDialogData(hDlg);

if((pData->dwCreateOptions & FILE_OPEN_BY_FILE_ID) == 0)
GetDlgItemText(hDlg, IDC_FILE_NAME1, pData->szFileName1, _maxchars(pData->szFileName1));
GetDlgItemText(hDlg, IDC_FILE_NAME2, pData->szFileName2, _maxchars(pData->szFileName2));
GetDlgItemText(hDlg, IDC_FILE_NAME1, pData->szFileName1, _countof(pData->szFileName1));
GetDlgItemText(hDlg, IDC_FILE_NAME2, pData->szFileName2, _countof(pData->szFileName2));
return ERROR_SUCCESS;
}

Expand Down Expand Up @@ -727,8 +727,8 @@ static int OnCopyFileClick(HWND hDlg)
DWORD dwErrCode;

// Get the source and target file
GetDlgItemText(hDlg, IDC_FILE_NAME1, pData->szFileName1, _maxchars(pData->szFileName1));
GetDlgItemText(hDlg, IDC_FILE_NAME2, pData->szFileName2, _maxchars(pData->szFileName2));
GetDlgItemText(hDlg, IDC_FILE_NAME1, pData->szFileName1, _countof(pData->szFileName1));
GetDlgItemText(hDlg, IDC_FILE_NAME2, pData->szFileName2, _countof(pData->szFileName2));

// Run the copy file dialog
dwErrCode = (DWORD)CopyFileDialog(hDlg, pData);
Expand Down Expand Up @@ -942,7 +942,7 @@ static int OnFileIdUse(HWND hDlg, UINT nIDEdit)
TCHAR szFileId[0x100] = _T("");

// Retrieve the file ID or object ID from the edit box
GetDlgItemText(hDlg, nIDEdit, szFileId, _maxchars(szFileId));
GetDlgItemText(hDlg, nIDEdit, szFileId, _countof(szFileId));
NtUseFileId(hDlg, szFileId);
return TRUE;
}
Expand Down Expand Up @@ -1010,7 +1010,7 @@ static int OnObjectIdMoreClick(HWND hDlg)

case IDC_SET_OBJECT_ID:

GetDlgItemText(hDlg, IDC_OBJECT_ID, szObjectID, _maxchars(szObjectID));
GetDlgItemText(hDlg, IDC_OBJECT_ID, szObjectID, _countof(szObjectID));
dwErrCode = StringToFileID(szObjectID, NULL, ObjId.ObjectId, NULL);
if(dwErrCode != ERROR_SUCCESS)
break;
Expand Down
16 changes: 8 additions & 8 deletions Page06NtFileInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1767,7 +1767,7 @@ static int InsertTreeItemFlags32(
pMemberInfo->pFlags = pMember->pFlags;

// Insert the tree item to the tree
if(DataToItemText(pMemberInfo, szItemText, _maxchars(szItemText), FALSE) == ERROR_SUCCESS)
if(DataToItemText(pMemberInfo, szItemText, _countof(szItemText), FALSE) == ERROR_SUCCESS)
InsertTreeItem(hTreeView, hParentItem, szItemText, pMemberInfo);
}

Expand Down Expand Up @@ -1852,7 +1852,7 @@ static int InsertTreeItemByDataType(
pMemberInfo->pbDataPtr = pbDataPtr;

// Get the item text
if(DataToItemText(pMemberInfo, szItemText, _maxchars(szItemText), FALSE) == ERROR_SUCCESS)
if(DataToItemText(pMemberInfo, szItemText, _countof(szItemText), FALSE) == ERROR_SUCCESS)
InsertTreeItem(hTreeView, hParentItem, szItemText, pMemberInfo);
}

Expand All @@ -1875,7 +1875,7 @@ static int InsertTreeItemByDataType(
pMemberInfo->pbDataPtr = pbDataPtr;

// Get the item text
if(DataToItemText(pMemberInfo, szItemText, _maxchars(szItemText), FALSE) == ERROR_SUCCESS)
if(DataToItemText(pMemberInfo, szItemText, _countof(szItemText), FALSE) == ERROR_SUCCESS)
InsertTreeItem(hTreeView, hParentItem, szItemText, pMemberInfo);
}
}
Expand Down Expand Up @@ -1967,7 +1967,7 @@ static int ReloadTreeViewItems(HWND hDlg, HWND hTreeView, HTREEITEM hParentItem)
if(pMemberInfo != NULL)
{
// Get the item text
if(DataToItemText(pMemberInfo, szItemText, _maxchars(szItemText), FALSE) == ERROR_SUCCESS)
if(DataToItemText(pMemberInfo, szItemText, _countof(szItemText), FALSE) == ERROR_SUCCESS)
{
ZeroMemory(&tvi, sizeof(TVITEM));
tvi.mask = TVIF_TEXT;
Expand Down Expand Up @@ -2469,9 +2469,9 @@ static int OnShowDateFormats(HWND hDlg, HWND hTreeItem, HTREEITEM hItem)
return TRUE;

// Prepare the text for the tooltip
LoadString(g_hInst, IDS_BAD_DATETIME_FORMAT, szTitle, _maxchars(szTitle));
LoadString(g_hInst, IDS_DATE_FORMAT_PREFIX, szDateFormatPrefix, _maxchars(szDateFormatPrefix));
LoadString(g_hInst, IDS_TIME_FORMAT_PREFIX, szTimeFormatPrefix, _maxchars(szTimeFormatPrefix));
LoadString(g_hInst, IDS_BAD_DATETIME_FORMAT, szTitle, _countof(szTitle));
LoadString(g_hInst, IDS_DATE_FORMAT_PREFIX, szDateFormatPrefix, _countof(szDateFormatPrefix));
LoadString(g_hInst, IDS_TIME_FORMAT_PREFIX, szTimeFormatPrefix, _countof(szTimeFormatPrefix));
GetSupportedDateTimeFormats(szDateFormatPrefix, szTimeFormatPrefix, szText, nMaxChars);

// Create the additional tooltip window
Expand Down Expand Up @@ -2583,7 +2583,7 @@ static int OnBeginLabelEdit(HWND hDlg, NMTVDISPINFO * pTVDispInfo)
if(hEdit != NULL)
{
// Get the item text
if(DataToItemText(pMemberInfo, szItemText, _maxchars(szItemText), TRUE) == ERROR_SUCCESS)
if(DataToItemText(pMemberInfo, szItemText, _countof(szItemText), TRUE) == ERROR_SUCCESS)
{
SetWindowText(hEdit, szItemText);
bStartEditing = TRUE;
Expand Down
14 changes: 7 additions & 7 deletions Page09Security.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -348,8 +348,8 @@ static void SidToString(PSID pvSid, LPTSTR szString, size_t cchString, bool bAdd
SID_NAME_USE SidNameUse;
TCHAR szDomainName[128] = _T("");
TCHAR szUserName[128] = _T("");
DWORD cchDomainName = _maxchars(szDomainName);
DWORD cchUserName = _maxchars(szUserName);
DWORD cchDomainName = _countof(szDomainName);
DWORD cchUserName = _countof(szUserName);

if(LookupAccountSid(NULL, pSid, szUserName, &cchUserName, szDomainName, &cchDomainName, &SidNameUse))
{
Expand All @@ -373,7 +373,7 @@ static bool StringToSid(LPTSTR szSid, PSID * ppSid)
TCHAR szDomainName[128] = _T("");
DWORD dwSubAuthCount = 0;
DWORD dwSubAuth[8];
DWORD dwDomainName = _maxchars(szDomainName);
DWORD dwDomainName = _countof(szDomainName);
DWORD dwRevision = SID_REVISION;
DWORD dwLength = 0;
BOOL bResult;
Expand Down Expand Up @@ -665,7 +665,7 @@ static bool TreeView_ItemToValue32(HWND hTreeView, HTREEITEM hItem, LPDWORD PtrV
tvi.mask = TVIF_TEXT;
tvi.hItem = hItem;
tvi.pszText = szItemText;
tvi.cchTextMax = _maxchars(szItemText);
tvi.cchTextMax = _countof(szItemText);
if(TreeView_GetItem(hTreeView, &tvi))
{
// Retrieve the value
Expand All @@ -691,7 +691,7 @@ static bool TreeView_ItemToGuid(HWND hTreeView, HTREEITEM hItem, LPGUID PtrGuid)
tvi.mask = TVIF_TEXT;
tvi.hItem = hItem;
tvi.pszText = szItemText;
tvi.cchTextMax = _maxchars(szItemText);
tvi.cchTextMax = _countof(szItemText);
if(TreeView_GetItem(hTreeView, &tvi))
{
// Retrieve the value
Expand Down Expand Up @@ -746,7 +746,7 @@ static bool TreeView_ItemToSid(HWND hTreeView, HTREEITEM hItem, PSID * ppSid, bo
tvi.mask = TVIF_TEXT | TVIF_PARAM;
tvi.hItem = hItem;
tvi.pszText = szItemText;
tvi.cchTextMax = _maxchars(szItemText);
tvi.cchTextMax = _countof(szItemText);
TreeView_GetItem(hTreeView, &tvi);

// Convert the tree item to SID
Expand Down Expand Up @@ -1191,7 +1191,7 @@ static void TreeView_SdToTreeView(

// Clear all current tree view items
TreeView_DeleteAllItems(hTreeView);
LoadString(g_hInst, IDS_NOT_PRESENT, szNotPresent, _maxchars(szNotPresent));
LoadString(g_hInst, IDS_NOT_PRESENT, szNotPresent, _countof(szNotPresent));

//
// Insert tree item for owner security information
Expand Down
Loading

0 comments on commit a29b9b0

Please sign in to comment.