advpack: Factor out writing predefined strings into write_predefined_strings.
This commit is contained in:
parent
4b9311b5b2
commit
f1631103aa
|
@ -38,6 +38,7 @@ static const WCHAR MOD_PATH[] = {'_','M','O','D','_','P','A','T','H',0};
|
||||||
static const WCHAR SYS_MOD_PATH[] = {'_','S','Y','S','_','M','O','D','_','P','A','T','H',0};
|
static const WCHAR SYS_MOD_PATH[] = {'_','S','Y','S','_','M','O','D','_','P','A','T','H',0};
|
||||||
static const WCHAR SystemRoot[] = {'S','y','s','t','e','m','R','o','o','t',0};
|
static const WCHAR SystemRoot[] = {'S','y','s','t','e','m','R','o','o','t',0};
|
||||||
static const WCHAR escaped_SystemRoot[] = {'%','S','y','s','t','e','m','R','o','o','t','%',0};
|
static const WCHAR escaped_SystemRoot[] = {'%','S','y','s','t','e','m','R','o','o','t','%',0};
|
||||||
|
static const WCHAR quote[] = {'\"',0};
|
||||||
|
|
||||||
static BOOL get_temp_ini_path(LPWSTR name)
|
static BOOL get_temp_ini_path(LPWSTR name)
|
||||||
{
|
{
|
||||||
|
@ -170,6 +171,39 @@ HRESULT WINAPI RegInstallA(HMODULE hm, LPCSTR pszSection, const STRTABLEA* pstTa
|
||||||
return hr;
|
return hr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static HRESULT write_predefined_strings(HMODULE hm, LPWSTR ini_path)
|
||||||
|
{
|
||||||
|
WCHAR mod_path[MAX_PATH + 2];
|
||||||
|
WCHAR sys_mod_path[MAX_PATH + 2];
|
||||||
|
WCHAR sys_root[MAX_PATH];
|
||||||
|
|
||||||
|
*mod_path = '\"';
|
||||||
|
if (!GetModuleFileNameW(hm, mod_path + 1, sizeof(mod_path) / sizeof(WCHAR) - 2))
|
||||||
|
return E_FAIL;
|
||||||
|
|
||||||
|
lstrcatW(mod_path, quote);
|
||||||
|
WritePrivateProfileStringW(Strings, MOD_PATH, mod_path, ini_path);
|
||||||
|
|
||||||
|
*sys_root = '\0';
|
||||||
|
GetEnvironmentVariableW(SystemRoot, sys_root, sizeof(sys_root) / sizeof(WCHAR));
|
||||||
|
|
||||||
|
if(!strncmpiW(sys_root, mod_path + 1, strlenW(sys_root)))
|
||||||
|
{
|
||||||
|
*sys_mod_path = '\"';
|
||||||
|
strcpyW(sys_mod_path + 1, escaped_SystemRoot);
|
||||||
|
strcatW(sys_mod_path, mod_path + 1 + strlenW(sys_root));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
FIXME("SYS_MOD_PATH needs more work\n");
|
||||||
|
strcpyW(sys_mod_path, mod_path);
|
||||||
|
}
|
||||||
|
|
||||||
|
WritePrivateProfileStringW(Strings, SYS_MOD_PATH, sys_mod_path, ini_path);
|
||||||
|
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
* RegInstallW (advpack.@)
|
* RegInstallW (advpack.@)
|
||||||
*
|
*
|
||||||
|
@ -189,32 +223,15 @@ HRESULT WINAPI RegInstallW(HMODULE hm, LPCWSTR pszSection, const STRTABLEW* pstT
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
WCHAR tmp_ini_path[MAX_PATH];
|
WCHAR tmp_ini_path[MAX_PATH];
|
||||||
WCHAR mod_path[MAX_PATH + 2], sys_mod_path[MAX_PATH + 2], sys_root[MAX_PATH];
|
HINF hinf = INVALID_HANDLE_VALUE;
|
||||||
HINF hinf;
|
|
||||||
static const WCHAR quote[] = {'\"',0};
|
|
||||||
|
|
||||||
TRACE("(%p, %s, %p)\n", hm, debugstr_w(pszSection), pstTable);
|
TRACE("(%p, %s, %p)\n", hm, debugstr_w(pszSection), pstTable);
|
||||||
|
|
||||||
if(!create_tmp_ini_file(hm, tmp_ini_path))
|
if(!create_tmp_ini_file(hm, tmp_ini_path))
|
||||||
return E_FAIL;
|
return E_FAIL;
|
||||||
|
|
||||||
/* Write a couple of pre-defined strings */
|
if (write_predefined_strings(hm, tmp_ini_path))
|
||||||
mod_path[0] = '\"';
|
goto done;
|
||||||
GetModuleFileNameW(hm, mod_path + 1, sizeof(mod_path)/sizeof(WCHAR) - 2);
|
|
||||||
strcatW(mod_path, quote);
|
|
||||||
WritePrivateProfileStringW(Strings, MOD_PATH, mod_path, tmp_ini_path);
|
|
||||||
|
|
||||||
*sys_root = '\0';
|
|
||||||
GetEnvironmentVariableW(SystemRoot, sys_root, sizeof(sys_root)/sizeof(WCHAR));
|
|
||||||
if(!strncmpiW(sys_root, mod_path + 1, strlenW(sys_root))) {
|
|
||||||
sys_mod_path[0] = '\"';
|
|
||||||
strcpyW(sys_mod_path + 1, escaped_SystemRoot);
|
|
||||||
strcatW(sys_mod_path, mod_path + 1 + strlenW(sys_root));
|
|
||||||
} else {
|
|
||||||
FIXME("SYS_MOD_PATH needs more work\n");
|
|
||||||
strcpyW(sys_mod_path, mod_path);
|
|
||||||
}
|
|
||||||
WritePrivateProfileStringW(Strings, SYS_MOD_PATH, sys_mod_path, tmp_ini_path);
|
|
||||||
|
|
||||||
/* Write the additional string table */
|
/* Write the additional string table */
|
||||||
if (pstTable) for(i = 0; i < pstTable->cEntries; i++) {
|
if (pstTable) for(i = 0; i < pstTable->cEntries; i++) {
|
||||||
|
@ -233,7 +250,7 @@ HRESULT WINAPI RegInstallW(HMODULE hm, LPCWSTR pszSection, const STRTABLEW* pstT
|
||||||
if((hinf = SetupOpenInfFileW(tmp_ini_path, NULL, INF_STYLE_WIN4, NULL)) ==
|
if((hinf = SetupOpenInfFileW(tmp_ini_path, NULL, INF_STYLE_WIN4, NULL)) ==
|
||||||
INVALID_HANDLE_VALUE) {
|
INVALID_HANDLE_VALUE) {
|
||||||
ERR("Setupapi can't open inf\n");
|
ERR("Setupapi can't open inf\n");
|
||||||
return E_FAIL;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* append any layout files */
|
/* append any layout files */
|
||||||
|
@ -244,7 +261,10 @@ HRESULT WINAPI RegInstallW(HMODULE hm, LPCWSTR pszSection, const STRTABLEW* pstT
|
||||||
SPINST_INIFILES | SPINST_REGISTRY | SPINST_PROFILEITEMS,
|
SPINST_INIFILES | SPINST_REGISTRY | SPINST_PROFILEITEMS,
|
||||||
HKEY_LOCAL_MACHINE, NULL, 0, NULL, NULL, NULL, NULL);
|
HKEY_LOCAL_MACHINE, NULL, 0, NULL, NULL, NULL, NULL);
|
||||||
|
|
||||||
|
done:
|
||||||
|
if (hinf != INVALID_HANDLE_VALUE)
|
||||||
SetupCloseInfFile(hinf);
|
SetupCloseInfFile(hinf);
|
||||||
|
|
||||||
DeleteFileW(tmp_ini_path);
|
DeleteFileW(tmp_ini_path);
|
||||||
|
|
||||||
return S_OK;
|
return S_OK;
|
||||||
|
|
Loading…
Reference in New Issue