📄 msi.c
字号:
INSTALLSTATE WINAPI MsiLocateComponentW(LPCWSTR szComponent, LPWSTR lpPathBuf,
DWORD *pcchBuf)
{
WCHAR szProduct[GUID_SIZE];
TRACE("%s %p %p\n", debugstr_w(szComponent), lpPathBuf, pcchBuf);
if (MsiGetProductCodeW( szComponent, szProduct ) != ERROR_SUCCESS)
return INSTALLSTATE_UNKNOWN;
return MsiGetComponentPathW( szProduct, szComponent, lpPathBuf, pcchBuf );
}
UINT WINAPI MsiMessageBoxA(HWND hWnd, LPCSTR lpText, LPCSTR lpCaption, UINT uType,
WORD wLanguageId, DWORD f)
{
FIXME("%p %s %s %u %08x %08x\n", hWnd, debugstr_a(lpText), debugstr_a(lpCaption),
uType, wLanguageId, f);
return MessageBoxExA(hWnd,lpText,lpCaption,uType,wLanguageId);
}
UINT WINAPI MsiMessageBoxW(HWND hWnd, LPCWSTR lpText, LPCWSTR lpCaption, UINT uType,
WORD wLanguageId, DWORD f)
{
FIXME("%p %s %s %u %08x %08x\n", hWnd, debugstr_w(lpText), debugstr_w(lpCaption),
uType, wLanguageId, f);
return MessageBoxExW(hWnd,lpText,lpCaption,uType,wLanguageId);
}
UINT WINAPI MsiProvideAssemblyA( LPCSTR szAssemblyName, LPCSTR szAppContext,
DWORD dwInstallMode, DWORD dwAssemblyInfo, LPSTR lpPathBuf,
DWORD* pcchPathBuf )
{
FIXME("%s %s %08x %08x %p %p\n", debugstr_a(szAssemblyName),
debugstr_a(szAppContext), dwInstallMode, dwAssemblyInfo, lpPathBuf,
pcchPathBuf);
return ERROR_CALL_NOT_IMPLEMENTED;
}
UINT WINAPI MsiProvideAssemblyW( LPCWSTR szAssemblyName, LPCWSTR szAppContext,
DWORD dwInstallMode, DWORD dwAssemblyInfo, LPWSTR lpPathBuf,
DWORD* pcchPathBuf )
{
FIXME("%s %s %08x %08x %p %p\n", debugstr_w(szAssemblyName),
debugstr_w(szAppContext), dwInstallMode, dwAssemblyInfo, lpPathBuf,
pcchPathBuf);
return ERROR_CALL_NOT_IMPLEMENTED;
}
UINT WINAPI MsiProvideComponentFromDescriptorA( LPCSTR szDescriptor,
LPSTR szPath, DWORD *pcchPath, DWORD *pcchArgs )
{
FIXME("%s %p %p %p\n", debugstr_a(szDescriptor), szPath, pcchPath, pcchArgs );
return ERROR_CALL_NOT_IMPLEMENTED;
}
UINT WINAPI MsiProvideComponentFromDescriptorW( LPCWSTR szDescriptor,
LPWSTR szPath, DWORD *pcchPath, DWORD *pcchArgs )
{
FIXME("%s %p %p %p\n", debugstr_w(szDescriptor), szPath, pcchPath, pcchArgs );
return ERROR_CALL_NOT_IMPLEMENTED;
}
HRESULT WINAPI MsiGetFileSignatureInformationA( LPCSTR szSignedObjectPath,
DWORD dwFlags, PCCERT_CONTEXT* ppcCertContext, BYTE* pbHashData,
DWORD* pcbHashData)
{
FIXME("%s %08x %p %p %p\n", debugstr_a(szSignedObjectPath), dwFlags,
ppcCertContext, pbHashData, pcbHashData);
return ERROR_CALL_NOT_IMPLEMENTED;
}
HRESULT WINAPI MsiGetFileSignatureInformationW( LPCWSTR szSignedObjectPath,
DWORD dwFlags, PCCERT_CONTEXT* ppcCertContext, BYTE* pbHashData,
DWORD* pcbHashData)
{
FIXME("%s %08x %p %p %p\n", debugstr_w(szSignedObjectPath), dwFlags,
ppcCertContext, pbHashData, pcbHashData);
return ERROR_CALL_NOT_IMPLEMENTED;
}
UINT WINAPI MsiGetProductPropertyA( MSIHANDLE hProduct, LPCSTR szProperty,
LPSTR szValue, DWORD *pccbValue )
{
FIXME("%ld %s %p %p\n", hProduct, debugstr_a(szProperty), szValue, pccbValue);
return ERROR_CALL_NOT_IMPLEMENTED;
}
UINT WINAPI MsiGetProductPropertyW( MSIHANDLE hProduct, LPCWSTR szProperty,
LPWSTR szValue, DWORD *pccbValue )
{
FIXME("%ld %s %p %p\n", hProduct, debugstr_w(szProperty), szValue, pccbValue);
return ERROR_CALL_NOT_IMPLEMENTED;
}
UINT WINAPI MsiVerifyPackageA( LPCSTR szPackage )
{
UINT r;
LPWSTR szPack = NULL;
TRACE("%s\n", debugstr_a(szPackage) );
if( szPackage )
{
szPack = strdupAtoW( szPackage );
if( !szPack )
return ERROR_OUTOFMEMORY;
}
r = MsiVerifyPackageW( szPack );
msi_free( szPack );
return r;
}
UINT WINAPI MsiVerifyPackageW( LPCWSTR szPackage )
{
MSIHANDLE handle;
UINT r;
TRACE("%s\n", debugstr_w(szPackage) );
r = MsiOpenDatabaseW( szPackage, MSIDBOPEN_READONLY, &handle );
MsiCloseHandle( handle );
return r;
}
static INSTALLSTATE WINAPI MSI_GetComponentPath(LPCWSTR szProduct, LPCWSTR szComponent,
awstring* lpPathBuf, DWORD* pcchBuf)
{
WCHAR squished_pc[GUID_SIZE], squished_comp[GUID_SIZE];
UINT rc;
HKEY hkey = 0;
LPWSTR path = NULL;
INSTALLSTATE r;
TRACE("%s %s %p %p\n", debugstr_w(szProduct),
debugstr_w(szComponent), lpPathBuf->str.w, pcchBuf);
if( !szProduct || !szComponent )
return INSTALLSTATE_INVALIDARG;
if( lpPathBuf->str.w && !pcchBuf )
return INSTALLSTATE_INVALIDARG;
if (!squash_guid( szProduct, squished_pc ) ||
!squash_guid( szComponent, squished_comp ))
return INSTALLSTATE_INVALIDARG;
rc = MSIREG_OpenProductsKey( szProduct, &hkey, FALSE);
if( rc != ERROR_SUCCESS )
return INSTALLSTATE_UNKNOWN;
RegCloseKey(hkey);
rc = MSIREG_OpenComponentsKey( szComponent, &hkey, FALSE);
if( rc != ERROR_SUCCESS )
return INSTALLSTATE_UNKNOWN;
path = msi_reg_get_val_str( hkey, squished_pc );
RegCloseKey(hkey);
TRACE("found path of (%s:%s)(%s)\n", debugstr_w(szComponent),
debugstr_w(szProduct), debugstr_w(path));
if (!path)
return INSTALLSTATE_UNKNOWN;
if (path[0])
r = INSTALLSTATE_LOCAL;
else
r = INSTALLSTATE_NOTUSED;
msi_strcpy_to_awstring( path, lpPathBuf, pcchBuf );
msi_free( path );
return r;
}
/******************************************************************
* MsiGetComponentPathW [MSI.@]
*/
INSTALLSTATE WINAPI MsiGetComponentPathW(LPCWSTR szProduct, LPCWSTR szComponent,
LPWSTR lpPathBuf, DWORD* pcchBuf)
{
awstring path;
path.unicode = TRUE;
path.str.w = lpPathBuf;
return MSI_GetComponentPath( szProduct, szComponent, &path, pcchBuf );
}
/******************************************************************
* MsiGetComponentPathA [MSI.@]
*/
INSTALLSTATE WINAPI MsiGetComponentPathA(LPCSTR szProduct, LPCSTR szComponent,
LPSTR lpPathBuf, DWORD* pcchBuf)
{
LPWSTR szwProduct, szwComponent = NULL;
INSTALLSTATE r = INSTALLSTATE_UNKNOWN;
awstring path;
szwProduct = strdupAtoW( szProduct );
if( szProduct && !szwProduct)
goto end;
szwComponent = strdupAtoW( szComponent );
if( szComponent && !szwComponent )
goto end;
path.unicode = FALSE;
path.str.a = lpPathBuf;
r = MSI_GetComponentPath( szwProduct, szwComponent, &path, pcchBuf );
end:
msi_free( szwProduct );
msi_free( szwComponent );
return r;
}
/******************************************************************
* MsiQueryFeatureStateA [MSI.@]
*/
INSTALLSTATE WINAPI MsiQueryFeatureStateA(LPCSTR szProduct, LPCSTR szFeature)
{
LPWSTR szwProduct = NULL, szwFeature= NULL;
INSTALLSTATE rc = INSTALLSTATE_UNKNOWN;
szwProduct = strdupAtoW( szProduct );
if ( szProduct && !szwProduct )
goto end;
szwFeature = strdupAtoW( szFeature );
if ( szFeature && !szwFeature )
goto end;
rc = MsiQueryFeatureStateW(szwProduct, szwFeature);
end:
msi_free( szwProduct);
msi_free( szwFeature);
return rc;
}
/******************************************************************
* MsiQueryFeatureStateW [MSI.@]
*
* Checks the state of a feature
*
* PARAMS
* szProduct [I] Product's GUID string
* szFeature [I] Feature's GUID string
*
* RETURNS
* INSTALLSTATE_LOCAL Feature is installed and useable
* INSTALLSTATE_ABSENT Feature is absent
* INSTALLSTATE_ADVERTISED Feature should be installed on demand
* INSTALLSTATE_UNKNOWN An error occurred
* INSTALLSTATE_INVALIDARG One of the GUIDs was invalid
*
*/
INSTALLSTATE WINAPI MsiQueryFeatureStateW(LPCWSTR szProduct, LPCWSTR szFeature)
{
WCHAR squishProduct[33], comp[GUID_SIZE];
GUID guid;
LPWSTR components, p, parent_feature;
UINT rc;
HKEY hkey;
INSTALLSTATE r;
BOOL missing = FALSE;
TRACE("%s %s\n", debugstr_w(szProduct), debugstr_w(szFeature));
if (!szProduct || !szFeature)
return INSTALLSTATE_INVALIDARG;
if (!squash_guid( szProduct, squishProduct ))
return INSTALLSTATE_INVALIDARG;
/* check that it's installed at all */
rc = MSIREG_OpenUserFeaturesKey(szProduct, &hkey, FALSE);
if (rc != ERROR_SUCCESS)
return INSTALLSTATE_UNKNOWN;
parent_feature = msi_reg_get_val_str( hkey, szFeature );
RegCloseKey(hkey);
if (!parent_feature)
return INSTALLSTATE_UNKNOWN;
r = (parent_feature[0] == 6) ? INSTALLSTATE_ABSENT : INSTALLSTATE_LOCAL;
msi_free(parent_feature);
if (r == INSTALLSTATE_ABSENT)
return r;
/* now check if it's complete or advertised */
rc = MSIREG_OpenFeaturesKey(szProduct, &hkey, FALSE);
if (rc != ERROR_SUCCESS)
return INSTALLSTATE_UNKNOWN;
components = msi_reg_get_val_str( hkey, szFeature );
RegCloseKey(hkey);
TRACE("rc = %d buffer = %s\n", rc, debugstr_w(components));
if (!components)
{
ERR("components missing %s %s\n",
debugstr_w(szProduct), debugstr_w(szFeature));
return INSTALLSTATE_UNKNOWN;
}
for( p = components; *p != 2 ; p += 20)
{
if (!decode_base85_guid( p, &guid ))
{
ERR("%s\n", debugstr_w(p));
break;
}
StringFromGUID2(&guid, comp, GUID_SIZE);
r = MsiGetComponentPathW(szProduct, comp, NULL, 0);
TRACE("component %s state %d\n", debugstr_guid(&guid), r);
switch (r)
{
case INSTALLSTATE_NOTUSED:
case INSTALLSTATE_LOCAL:
case INSTALLSTATE_SOURCE:
break;
default:
missing = TRUE;
}
}
TRACE("%s %s -> %d\n", debugstr_w(szProduct), debugstr_w(szFeature), r);
msi_free(components);
if (missing)
return INSTALLSTATE_ADVERTISED;
return INSTALLSTATE_LOCAL;
}
/******************************************************************
* MsiGetFileVersionA [MSI.@]
*/
UINT WINAPI MsiGetFileVersionA(LPCSTR szFilePath, LPSTR lpVersionBuf,
DWORD* pcchVersionBuf, LPSTR lpLangBuf, DWORD* pcchLangBuf)
{
LPWSTR szwFilePath = NULL, lpwVersionBuff = NULL, lpwLangBuff = NULL;
UINT ret = ERROR_OUTOFMEMORY;
if( szFilePath )
{
szwFilePath = strdupAtoW( szFilePath );
if( !szwFilePath )
goto end;
}
if( lpVersionBuf && pcchVersionBuf && *pcchVersionBuf )
{
lpwVersionBuff = msi_alloc(*pcchVersionBuf*sizeof(WCHAR));
if( !lpwVersionBuff )
goto end;
}
if( lpLangBuf && pcchLangBuf && *pcchLangBuf )
{
lpwLangBuff = msi_alloc(*pcchVersionBuf*sizeof(WCHAR));
if( !lpwLangBuff )
goto end;
}
ret = MsiGetFileVersionW(szwFilePath, lpwVersionBuff, pcchVersionBuf,
lpwLangBuff, pcchLangBuf);
if( lpwVersionBuff )
WideCharToMultiByte(CP_ACP, 0, lpwVersionBuff, -1,
lpVersionBuf, *pcchVersionBuf, NULL, NULL);
if( lpwLangBuff )
WideCharToMultiByte(CP_ACP, 0, lpwLangBuff, -1,
lpLangBuf, *pcchLangBuf, NULL, NULL);
end:
msi_free(szwFilePath);
msi_free(lpwVersionBuff);
msi_free(lpwLangBuff);
return ret;
}
/******************************************************************
* MsiGetFileVersionW [MSI.@]
*/
UINT WINAPI MsiGetFileVersionW(LPCWSTR szFilePath, LPWSTR lpVersionBuf,
DWORD* pcchVersionBuf, LPWSTR lpLangBuf, DWORD* pcchLangBuf)
{
static WCHAR szVersionResource[] = {'\\',0};
static const WCHAR szVersionFormat[] = {
'%','d','.','%','d','.','%','d','.','%','d',0};
static const WCHAR szLangFormat[] = {'%','d',0};
UINT ret = 0;
DWORD dwVerLen;
LPVOID lpVer = NULL;
VS_FIXEDFILEINFO *ffi;
UINT puLen;
WCHAR tmp[32];
TRACE("%s %p %d %p %d\n", debugstr_w(szFilePath),
lpVersionBuf, pcchVersionBuf?*pcchVersionBuf:0,
lpLangBuf, pcchLangBuf?*pcchLangBuf:0);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -