msi: Read from the registry, not the database in MsiGetProductInfo.
This commit is contained in:
parent
a3c03fea58
commit
cd5bac0b3d
131
dlls/msi/msi.c
131
dlls/msi/msi.c
|
@ -512,95 +512,114 @@ end:
|
||||||
UINT WINAPI MsiGetProductInfoW(LPCWSTR szProduct, LPCWSTR szAttribute,
|
UINT WINAPI MsiGetProductInfoW(LPCWSTR szProduct, LPCWSTR szAttribute,
|
||||||
LPWSTR szBuffer, DWORD *pcchValueBuf)
|
LPWSTR szBuffer, DWORD *pcchValueBuf)
|
||||||
{
|
{
|
||||||
MSIHANDLE hProduct;
|
|
||||||
UINT r;
|
UINT r;
|
||||||
static const WCHAR szProductVersion[] =
|
HKEY hkey;
|
||||||
{'P','r','o','d','u','c','t','V','e','r','s','i','o','n',0};
|
LPWSTR val = NULL;
|
||||||
static const WCHAR szProductLanguage[] =
|
|
||||||
{'P','r','o','d','u','c','t','L','a','n','g','u','a','g','e',0};
|
|
||||||
|
|
||||||
FIXME("%s %s %p %p\n",debugstr_w(szProduct), debugstr_w(szAttribute),
|
FIXME("%s %s %p %p\n",debugstr_w(szProduct), debugstr_w(szAttribute),
|
||||||
szBuffer, pcchValueBuf);
|
szBuffer, pcchValueBuf);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* FIXME:
|
||||||
|
*
|
||||||
|
* We should use msi_strcpy_to_awstring to return strings.
|
||||||
|
*
|
||||||
|
* The values seem scattered/dupicated in the registry. Is there a system?
|
||||||
|
*/
|
||||||
|
|
||||||
if (NULL != szBuffer && NULL == pcchValueBuf)
|
if (NULL != szBuffer && NULL == pcchValueBuf)
|
||||||
return ERROR_INVALID_PARAMETER;
|
return ERROR_INVALID_PARAMETER;
|
||||||
if (NULL == szProduct || NULL == szAttribute)
|
if (NULL == szProduct || NULL == szAttribute)
|
||||||
return ERROR_INVALID_PARAMETER;
|
return ERROR_INVALID_PARAMETER;
|
||||||
|
|
||||||
/* check for special properties */
|
/* check for special properties */
|
||||||
if (strcmpW(szAttribute, INSTALLPROPERTY_PACKAGECODEW)==0)
|
if (!lstrcmpW(szAttribute, INSTALLPROPERTY_PACKAGECODEW))
|
||||||
{
|
{
|
||||||
HKEY hkey;
|
LPWSTR regval;
|
||||||
WCHAR squished[GUID_SIZE];
|
WCHAR packagecode[35];
|
||||||
WCHAR package[200];
|
|
||||||
DWORD sz = sizeof(squished);
|
|
||||||
|
|
||||||
r = MSIREG_OpenUserProductsKey(szProduct, &hkey, FALSE);
|
r = MSIREG_OpenUserProductsKey(szProduct, &hkey, FALSE);
|
||||||
if (r != ERROR_SUCCESS)
|
if (r != ERROR_SUCCESS)
|
||||||
return ERROR_UNKNOWN_PRODUCT;
|
return ERROR_UNKNOWN_PRODUCT;
|
||||||
|
|
||||||
r = RegQueryValueExW(hkey, INSTALLPROPERTY_PACKAGECODEW, NULL, NULL,
|
regval = msi_reg_get_val_str( hkey, szAttribute );
|
||||||
(LPBYTE)squished, &sz);
|
if (regval)
|
||||||
if (r != ERROR_SUCCESS)
|
|
||||||
{
|
{
|
||||||
RegCloseKey(hkey);
|
if (unsquash_guid(regval, packagecode))
|
||||||
return ERROR_UNKNOWN_PRODUCT;
|
val = strdupW(packagecode);
|
||||||
|
msi_free(regval);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsquash_guid(squished, package);
|
|
||||||
*pcchValueBuf = strlenW(package);
|
|
||||||
if (strlenW(package) > *pcchValueBuf)
|
|
||||||
{
|
|
||||||
RegCloseKey(hkey);
|
|
||||||
return ERROR_MORE_DATA;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
strcpyW(szBuffer, package);
|
|
||||||
|
|
||||||
RegCloseKey(hkey);
|
RegCloseKey(hkey);
|
||||||
r = ERROR_SUCCESS;
|
|
||||||
}
|
}
|
||||||
else if (strcmpW(szAttribute, INSTALLPROPERTY_VERSIONSTRINGW)==0)
|
else if (!lstrcmpW(szAttribute, INSTALLPROPERTY_ASSIGNMENTTYPEW))
|
||||||
{
|
{
|
||||||
r = MsiOpenProductW(szProduct, &hProduct);
|
static const WCHAR one[] = { '1',0 };
|
||||||
if (ERROR_SUCCESS != r)
|
/*
|
||||||
return r;
|
* FIXME: should be in the Product key (user or system?)
|
||||||
|
* but isn't written yet...
|
||||||
|
*/
|
||||||
|
val = strdupW( one );
|
||||||
|
}
|
||||||
|
else if (!lstrcmpW(szAttribute, INSTALLPROPERTY_LANGUAGEW) ||
|
||||||
|
!lstrcmpW(szAttribute, INSTALLPROPERTY_VERSIONW))
|
||||||
|
{
|
||||||
|
static const WCHAR fmt[] = { '%','u',0 };
|
||||||
|
WCHAR szVal[16];
|
||||||
|
DWORD regval;
|
||||||
|
|
||||||
r = MsiGetPropertyW(hProduct, szProductVersion, szBuffer, pcchValueBuf);
|
r = MSIREG_OpenUninstallKey(szProduct, &hkey, FALSE);
|
||||||
MsiCloseHandle(hProduct);
|
if (r != ERROR_SUCCESS)
|
||||||
}
|
return ERROR_UNKNOWN_PRODUCT;
|
||||||
else if (strcmpW(szAttribute, INSTALLPROPERTY_ASSIGNMENTTYPEW)==0)
|
|
||||||
{
|
if (msi_reg_get_val_dword( hkey, szAttribute, ®val))
|
||||||
FIXME("0 (zero) if advertised or per user , 1(one) if per machine.\n");
|
|
||||||
if (szBuffer)
|
|
||||||
{
|
{
|
||||||
szBuffer[0] = '1';
|
sprintfW(szVal, fmt, regval);
|
||||||
szBuffer[1] = 0;
|
val = strdupW( szVal );
|
||||||
}
|
}
|
||||||
if (pcchValueBuf)
|
|
||||||
*pcchValueBuf = 1;
|
|
||||||
r = ERROR_SUCCESS;
|
|
||||||
}
|
|
||||||
else if (strcmpW(szAttribute, INSTALLPROPERTY_LANGUAGEW)==0)
|
|
||||||
{
|
|
||||||
r = MsiOpenProductW(szProduct, &hProduct);
|
|
||||||
if (ERROR_SUCCESS != r)
|
|
||||||
return r;
|
|
||||||
|
|
||||||
r = MsiGetPropertyW(hProduct, szProductLanguage, szBuffer, pcchValueBuf);
|
RegCloseKey(hkey);
|
||||||
MsiCloseHandle(hProduct);
|
}
|
||||||
|
else if (!lstrcmpW(szAttribute, INSTALLPROPERTY_PRODUCTNAMEW))
|
||||||
|
{
|
||||||
|
r = MSIREG_OpenUserProductsKey(szProduct, &hkey, FALSE);
|
||||||
|
if (r != ERROR_SUCCESS)
|
||||||
|
return ERROR_UNKNOWN_PRODUCT;
|
||||||
|
|
||||||
|
val = msi_reg_get_val_str( hkey, szAttribute );
|
||||||
|
|
||||||
|
RegCloseKey(hkey);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
r = MsiOpenProductW(szProduct, &hProduct);
|
static const WCHAR szDisplayVersion[] = {
|
||||||
if (ERROR_SUCCESS != r)
|
'D','i','s','p','l','a','y','V','e','r','s','i','o','n',0 };
|
||||||
return r;
|
|
||||||
|
|
||||||
r = MsiGetPropertyW(hProduct, szAttribute, szBuffer, pcchValueBuf);
|
if (!lstrcmpW(szAttribute, INSTALLPROPERTY_VERSIONSTRINGW))
|
||||||
MsiCloseHandle(hProduct);
|
szAttribute = szDisplayVersion;
|
||||||
|
|
||||||
|
r = MSIREG_OpenUninstallKey(szProduct, &hkey, FALSE);
|
||||||
|
if (r != ERROR_SUCCESS)
|
||||||
|
return ERROR_UNKNOWN_PRODUCT;
|
||||||
|
|
||||||
|
val = msi_reg_get_val_str( hkey, szAttribute );
|
||||||
|
|
||||||
|
RegCloseKey(hkey);
|
||||||
}
|
}
|
||||||
|
|
||||||
return r;
|
TRACE("returning %s\n", debugstr_w(val));
|
||||||
|
|
||||||
|
if (!val)
|
||||||
|
return ERROR_UNKNOWN_PROPERTY;
|
||||||
|
|
||||||
|
if (lstrlenW(val) > *pcchValueBuf)
|
||||||
|
return ERROR_MORE_DATA;
|
||||||
|
|
||||||
|
lstrcpyW(szBuffer, val);
|
||||||
|
|
||||||
|
HeapFree(GetProcessHeap(), 0, val);
|
||||||
|
|
||||||
|
return ERROR_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
UINT WINAPI MsiEnableLogA(DWORD dwLogMode, LPCSTR szLogFile, DWORD attributes)
|
UINT WINAPI MsiEnableLogA(DWORD dwLogMode, LPCSTR szLogFile, DWORD attributes)
|
||||||
|
|
Loading…
Reference in New Issue