msi: Use awstring to return strings from MsiGetProductInfo.

This commit is contained in:
Mike McCormack 2006-07-14 15:21:10 +09:00 committed by Alexandre Julliard
parent cd5bac0b3d
commit c19f9e9c31
1 changed files with 68 additions and 80 deletions

View File

@ -457,79 +457,21 @@ UINT WINAPI MsiGetProductCodeW(LPCWSTR szComponent, LPWSTR szBuffer)
return ERROR_SUCCESS;
}
UINT WINAPI MsiGetProductInfoA(LPCSTR szProduct, LPCSTR szAttribute,
LPSTR szBuffer, DWORD *pcchValueBuf)
{
LPWSTR szwProduct = NULL, szwAttribute = NULL, szwBuffer = NULL;
UINT r = ERROR_OUTOFMEMORY;
DWORD pcchwValueBuf = 0;
TRACE("%s %s %p %p\n", debugstr_a(szProduct), debugstr_a(szAttribute),
szBuffer, pcchValueBuf);
if( szProduct )
{
szwProduct = strdupAtoW( szProduct );
if( !szwProduct )
goto end;
}
if( szAttribute )
{
szwAttribute = strdupAtoW( szAttribute );
if( !szwAttribute )
goto end;
}
if( szBuffer )
{
szwBuffer = msi_alloc( (*pcchValueBuf) * sizeof(WCHAR) );
pcchwValueBuf = *pcchValueBuf;
if( !szwBuffer )
goto end;
}
r = MsiGetProductInfoW( szwProduct, szwAttribute, szwBuffer,
&pcchwValueBuf );
if( ERROR_SUCCESS == r )
{
INT old_len = *pcchValueBuf;
*pcchValueBuf = WideCharToMultiByte(CP_ACP, 0, szwBuffer, pcchwValueBuf,
szBuffer, *pcchValueBuf, NULL, NULL);
if (old_len > *pcchValueBuf)
szBuffer[*pcchValueBuf]=0;
}
end:
msi_free( szwProduct );
msi_free( szwAttribute );
msi_free( szwBuffer );
return r;
}
UINT WINAPI MsiGetProductInfoW(LPCWSTR szProduct, LPCWSTR szAttribute,
LPWSTR szBuffer, DWORD *pcchValueBuf)
UINT WINAPI MSI_GetProductInfo(LPCWSTR szProduct, LPCWSTR szAttribute,
awstring *szValue, DWORD *pcchValueBuf)
{
UINT r;
HKEY hkey;
LPWSTR val = NULL;
FIXME("%s %s %p %p\n",debugstr_w(szProduct), debugstr_w(szAttribute),
szBuffer, pcchValueBuf);
TRACE("%s %s %p %p\n", debugstr_w(szProduct),
debugstr_w(szAttribute), szValue, pcchValueBuf);
/*
* FIXME:
*
* We should use msi_strcpy_to_awstring to return strings.
*
* The values seem scattered/dupicated in the registry. Is there a system?
* FIXME: Values seem scattered/duplicated in the registry. Is there a system?
*/
if (NULL != szBuffer && NULL == pcchValueBuf)
return ERROR_INVALID_PARAMETER;
if (NULL == szProduct || NULL == szAttribute)
if ((szValue && !pcchValueBuf) || !szProduct || !szAttribute)
return ERROR_INVALID_PARAMETER;
/* check for special properties */
@ -595,6 +537,9 @@ UINT WINAPI MsiGetProductInfoW(LPCWSTR szProduct, LPCWSTR szAttribute,
static const WCHAR szDisplayVersion[] = {
'D','i','s','p','l','a','y','V','e','r','s','i','o','n',0 };
FIXME("%s\n", debugstr_w(szAttribute));
/* FIXME: some attribute values not tested... */
if (!lstrcmpW( szAttribute, INSTALLPROPERTY_VERSIONSTRINGW ))
szAttribute = szDisplayVersion;
@ -612,14 +557,57 @@ UINT WINAPI MsiGetProductInfoW(LPCWSTR szProduct, LPCWSTR szAttribute,
if (!val)
return ERROR_UNKNOWN_PROPERTY;
if (lstrlenW(val) > *pcchValueBuf)
return ERROR_MORE_DATA;
lstrcpyW(szBuffer, val);
r = msi_strcpy_to_awstring( val, szValue, pcchValueBuf );
HeapFree(GetProcessHeap(), 0, val);
return ERROR_SUCCESS;
return r;
}
UINT WINAPI MsiGetProductInfoA(LPCSTR szProduct, LPCSTR szAttribute,
LPSTR szBuffer, DWORD *pcchValueBuf)
{
LPWSTR szwProduct, szwAttribute = NULL;
UINT r = ERROR_OUTOFMEMORY;
awstring buffer;
TRACE("%s %s %p %p\n", debugstr_a(szProduct), debugstr_a(szAttribute),
szBuffer, pcchValueBuf);
szwProduct = strdupAtoW( szProduct );
if( szProduct && !szwProduct )
goto end;
szwAttribute = strdupAtoW( szAttribute );
if( szAttribute && !szwAttribute )
goto end;
buffer.unicode = FALSE;
buffer.str.a = szBuffer;
r = MSI_GetProductInfo( szwProduct, szwAttribute,
&buffer, pcchValueBuf );
end:
msi_free( szwProduct );
msi_free( szwAttribute );
return r;
}
UINT WINAPI MsiGetProductInfoW(LPCWSTR szProduct, LPCWSTR szAttribute,
LPWSTR szBuffer, DWORD *pcchValueBuf)
{
awstring buffer;
TRACE("%s %s %p %p\n", debugstr_w(szProduct), debugstr_w(szAttribute),
szBuffer, pcchValueBuf);
buffer.unicode = TRUE;
buffer.str.w = szBuffer;
return MSI_GetProductInfo( szProduct, szAttribute,
&buffer, pcchValueBuf );
}
UINT WINAPI MsiEnableLogA(DWORD dwLogMode, LPCSTR szLogFile, DWORD attributes)