Commit e7f5dc19 authored by André Hentschel's avatar André Hentschel Committed by Alexandre Julliard

advpack: Use ARRAY_SIZE() macro.

parent fc8d9692
...@@ -530,18 +530,12 @@ HRESULT WINAPI SetPerUserSecValuesA(PERUSERSECTIONA* pPerUser) ...@@ -530,18 +530,12 @@ HRESULT WINAPI SetPerUserSecValuesA(PERUSERSECTIONA* pPerUser)
if (!pPerUser) if (!pPerUser)
return E_INVALIDARG; return E_INVALIDARG;
MultiByteToWideChar(CP_ACP, 0, pPerUser->szGUID, -1, perUserW.szGUID, MultiByteToWideChar(CP_ACP, 0, pPerUser->szGUID, -1, perUserW.szGUID, ARRAY_SIZE(perUserW.szGUID));
sizeof(perUserW.szGUID) / sizeof(WCHAR)); MultiByteToWideChar(CP_ACP, 0, pPerUser->szDispName, -1, perUserW.szDispName, ARRAY_SIZE(perUserW.szDispName));
MultiByteToWideChar(CP_ACP, 0, pPerUser->szDispName, -1, perUserW.szDispName, MultiByteToWideChar(CP_ACP, 0, pPerUser->szLocale, -1, perUserW.szLocale, ARRAY_SIZE(perUserW.szLocale));
sizeof(perUserW.szDispName) / sizeof(WCHAR)); MultiByteToWideChar(CP_ACP, 0, pPerUser->szStub, -1, perUserW.szStub, ARRAY_SIZE(perUserW.szStub));
MultiByteToWideChar(CP_ACP, 0, pPerUser->szLocale, -1, perUserW.szLocale, MultiByteToWideChar(CP_ACP, 0, pPerUser->szVersion, -1, perUserW.szVersion, ARRAY_SIZE(perUserW.szVersion));
sizeof(perUserW.szLocale) / sizeof(WCHAR)); MultiByteToWideChar(CP_ACP, 0, pPerUser->szCompID, -1, perUserW.szCompID, ARRAY_SIZE(perUserW.szCompID));
MultiByteToWideChar(CP_ACP, 0, pPerUser->szStub, -1, perUserW.szStub,
sizeof(perUserW.szStub) / sizeof(WCHAR));
MultiByteToWideChar(CP_ACP, 0, pPerUser->szVersion, -1, perUserW.szVersion,
sizeof(perUserW.szVersion) / sizeof(WCHAR));
MultiByteToWideChar(CP_ACP, 0, pPerUser->szCompID, -1, perUserW.szCompID,
sizeof(perUserW.szCompID) / sizeof(WCHAR));
perUserW.dwIsInstalled = pPerUser->dwIsInstalled; perUserW.dwIsInstalled = pPerUser->dwIsInstalled;
perUserW.bRollback = pPerUser->bRollback; perUserW.bRollback = pPerUser->bRollback;
......
...@@ -115,28 +115,22 @@ static HRESULT per_user_install_callback(HINF hinf, PCWSTR field, const void *ar ...@@ -115,28 +115,22 @@ static HRESULT per_user_install_callback(HINF hinf, PCWSTR field, const void *ar
per_user.bRollback = FALSE; per_user.bRollback = FALSE;
per_user.dwIsInstalled = 0; per_user.dwIsInstalled = 0;
SetupGetLineTextW(NULL, hinf, field, disp_name, per_user.szDispName, SetupGetLineTextW(NULL, hinf, field, disp_name, per_user.szDispName, ARRAY_SIZE(per_user.szDispName), &size);
sizeof(per_user.szDispName) / sizeof(WCHAR), &size);
SetupGetLineTextW(NULL, hinf, field, version, per_user.szVersion, SetupGetLineTextW(NULL, hinf, field, version, per_user.szVersion, ARRAY_SIZE(per_user.szVersion), &size);
sizeof(per_user.szVersion) / sizeof(WCHAR), &size);
if (SetupFindFirstLineW(hinf, field, is_installed, &context)) if (SetupFindFirstLineW(hinf, field, is_installed, &context))
{ {
SetupGetIntField(&context, 1, (PINT)&per_user.dwIsInstalled); SetupGetIntField(&context, 1, (PINT)&per_user.dwIsInstalled);
} }
SetupGetLineTextW(NULL, hinf, field, comp_id, per_user.szCompID, SetupGetLineTextW(NULL, hinf, field, comp_id, per_user.szCompID, ARRAY_SIZE(per_user.szCompID), &size);
sizeof(per_user.szCompID) / sizeof(WCHAR), &size);
SetupGetLineTextW(NULL, hinf, field, guid, per_user.szGUID, SetupGetLineTextW(NULL, hinf, field, guid, per_user.szGUID, ARRAY_SIZE(per_user.szGUID), &size);
sizeof(per_user.szGUID) / sizeof(WCHAR), &size);
SetupGetLineTextW(NULL, hinf, field, locale, per_user.szLocale, SetupGetLineTextW(NULL, hinf, field, locale, per_user.szLocale, ARRAY_SIZE(per_user.szLocale), &size);
sizeof(per_user.szLocale) / sizeof(WCHAR), &size);
SetupGetLineTextW(NULL, hinf, field, stub_path, per_user.szStub, SetupGetLineTextW(NULL, hinf, field, stub_path, per_user.szStub, ARRAY_SIZE(per_user.szStub), &size);
sizeof(per_user.szStub) / sizeof(WCHAR), &size);
return SetPerUserSecValuesW(&per_user); return SetPerUserSecValuesW(&per_user);
} }
...@@ -154,8 +148,7 @@ static HRESULT register_ocxs_callback(HINF hinf, PCWSTR field, const void *arg) ...@@ -154,8 +148,7 @@ static HRESULT register_ocxs_callback(HINF hinf, PCWSTR field, const void *arg)
WCHAR buffer[MAX_INF_STRING_LENGTH]; WCHAR buffer[MAX_INF_STRING_LENGTH];
/* get OCX filename */ /* get OCX filename */
if (!SetupGetStringFieldW(&context, 1, buffer, if (!SetupGetStringFieldW(&context, 1, buffer, ARRAY_SIZE(buffer), NULL))
sizeof(buffer) / sizeof(WCHAR), NULL))
continue; continue;
hm = LoadLibraryExW(buffer, NULL, LOAD_WITH_ALTERED_SEARCH_PATH); hm = LoadLibraryExW(buffer, NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
...@@ -273,7 +266,7 @@ static HRESULT iterate_section_fields(HINF hinf, PCWSTR section, PCWSTR key, ...@@ -273,7 +266,7 @@ static HRESULT iterate_section_fields(HINF hinf, PCWSTR section, PCWSTR key,
{ {
WCHAR static_buffer[200]; WCHAR static_buffer[200];
WCHAR *buffer = static_buffer; WCHAR *buffer = static_buffer;
DWORD size = sizeof(static_buffer) / sizeof(WCHAR); DWORD size = ARRAY_SIZE(static_buffer);
INFCONTEXT context; INFCONTEXT context;
HRESULT hr = E_FAIL; HRESULT hr = E_FAIL;
...@@ -645,8 +638,7 @@ HRESULT WINAPI ExecuteCabA(HWND hwnd, CABINFOA* pCab, LPVOID pReserved) ...@@ -645,8 +638,7 @@ HRESULT WINAPI ExecuteCabA(HWND hwnd, CABINFOA* pCab, LPVOID pReserved)
RtlCreateUnicodeStringFromAsciiz(&inf, pCab->pszInf); RtlCreateUnicodeStringFromAsciiz(&inf, pCab->pszInf);
RtlCreateUnicodeStringFromAsciiz(&section, pCab->pszSection); RtlCreateUnicodeStringFromAsciiz(&section, pCab->pszSection);
MultiByteToWideChar(CP_ACP, 0, pCab->szSrcPath, -1, cabinfo.szSrcPath, MultiByteToWideChar(CP_ACP, 0, pCab->szSrcPath, -1, cabinfo.szSrcPath, ARRAY_SIZE(cabinfo.szSrcPath));
sizeof(cabinfo.szSrcPath) / sizeof(WCHAR));
cabinfo.pszInf = inf.Buffer; cabinfo.pszInf = inf.Buffer;
cabinfo.pszSection = section.Buffer; cabinfo.pszSection = section.Buffer;
......
...@@ -44,7 +44,7 @@ static BOOL get_temp_ini_path(LPWSTR name) ...@@ -44,7 +44,7 @@ static BOOL get_temp_ini_path(LPWSTR name)
WCHAR tmp_dir[MAX_PATH]; WCHAR tmp_dir[MAX_PATH];
WCHAR prefix[] = {'a','v','p',0}; WCHAR prefix[] = {'a','v','p',0};
if(!GetTempPathW(sizeof(tmp_dir)/sizeof(WCHAR), tmp_dir)) if(!GetTempPathW(ARRAY_SIZE(tmp_dir), tmp_dir))
return FALSE; return FALSE;
if(!GetTempFileNameW(tmp_dir, prefix, 0, name)) if(!GetTempFileNameW(tmp_dir, prefix, 0, name))
...@@ -177,14 +177,14 @@ static HRESULT write_predefined_strings(HMODULE hm, LPCWSTR ini_path) ...@@ -177,14 +177,14 @@ static HRESULT write_predefined_strings(HMODULE hm, LPCWSTR ini_path)
WCHAR sys_root[MAX_PATH]; WCHAR sys_root[MAX_PATH];
*mod_path = '\"'; *mod_path = '\"';
if (!GetModuleFileNameW(hm, mod_path + 1, sizeof(mod_path) / sizeof(WCHAR) - 2)) if (!GetModuleFileNameW(hm, mod_path + 1, ARRAY_SIZE(mod_path) - 2))
return E_FAIL; return E_FAIL;
lstrcatW(mod_path, quote); lstrcatW(mod_path, quote);
WritePrivateProfileStringW(Strings, MOD_PATH, mod_path, ini_path); WritePrivateProfileStringW(Strings, MOD_PATH, mod_path, ini_path);
*sys_root = '\0'; *sys_root = '\0';
GetEnvironmentVariableW(SystemRoot, sys_root, sizeof(sys_root) / sizeof(WCHAR)); GetEnvironmentVariableW(SystemRoot, sys_root, ARRAY_SIZE(sys_root));
if(!strncmpiW(sys_root, mod_path + 1, strlenW(sys_root))) if(!strncmpiW(sys_root, mod_path + 1, strlenW(sys_root)))
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment