Module: wine Branch: refs/heads/master Commit: 4c0e72ecebb75290625cf0e09a8302fd775026d5 URL: http://source.winehq.org/git/?p=wine.git;a=commit;h=4c0e72ecebb75290625cf0e0...
Author: Mike McCormack mike@codeweavers.com Date: Thu Jul 6 19:00:45 2006 +0900
msi: Use msi_strcpy_to_awstring to return the string in MsiComponentGetPath.
---
dlls/msi/msi.c | 149 ++++++++++++++++++++++++++------------------------------ 1 files changed, 70 insertions(+), 79 deletions(-)
diff --git a/dlls/msi/msi.c b/dlls/msi/msi.c index 119a4f9..d3c2179 100644 --- a/dlls/msi/msi.c +++ b/dlls/msi/msi.c @@ -974,58 +974,8 @@ UINT WINAPI MsiVerifyPackageW( LPCWSTR s return r; }
-INSTALLSTATE WINAPI MsiGetComponentPathA(LPCSTR szProduct, LPCSTR szComponent, - LPSTR lpPathBuf, DWORD* pcchBuf) -{ - LPWSTR szwProduct = NULL, szwComponent = NULL, lpwPathBuf= NULL; - INSTALLSTATE rc; - UINT incoming_len; - - if( szProduct ) - { - szwProduct = strdupAtoW( szProduct ); - if( !szwProduct) - return ERROR_OUTOFMEMORY; - } - - if( szComponent ) - { - szwComponent = strdupAtoW( szComponent ); - if( !szwComponent ) - { - msi_free( szwProduct); - return ERROR_OUTOFMEMORY; - } - } - - if( pcchBuf && *pcchBuf > 0 ) - { - lpwPathBuf = msi_alloc( *pcchBuf * sizeof(WCHAR)); - incoming_len = *pcchBuf; - } - else - { - lpwPathBuf = NULL; - incoming_len = 0; - } - - rc = MsiGetComponentPathW(szwProduct, szwComponent, lpwPathBuf, pcchBuf); - - msi_free( szwProduct); - msi_free( szwComponent); - if (lpwPathBuf) - { - if (rc != INSTALLSTATE_UNKNOWN) - WideCharToMultiByte(CP_ACP, 0, lpwPathBuf, incoming_len, - lpPathBuf, incoming_len, NULL, NULL); - msi_free( lpwPathBuf); - } - - return rc; -} - -INSTALLSTATE WINAPI MsiGetComponentPathW(LPCWSTR szProduct, LPCWSTR szComponent, - LPWSTR lpPathBuf, DWORD* pcchBuf) +INSTALLSTATE WINAPI MSI_GetComponentPath(LPCWSTR szProduct, LPCWSTR szComponent, + awstring* lpPathBuf, DWORD* pcchBuf) { WCHAR squished_pc[GUID_SIZE]; UINT rc; @@ -1042,38 +992,44 @@ INSTALLSTATE WINAPI MsiGetComponentPathW if( lpPathBuf && !pcchBuf ) return INSTALLSTATE_INVALIDARG;
- squash_guid(szProduct,squished_pc); + squash_guid( szProduct, squished_pc );
rc = MSIREG_OpenProductsKey( szProduct, &hkey, FALSE); if( rc != ERROR_SUCCESS ) - goto end; + return INSTALLSTATE_UNKNOWN;
RegCloseKey(hkey);
rc = MSIREG_OpenComponentsKey( szComponent, &hkey, FALSE); if( rc != ERROR_SUCCESS ) - goto end; + return INSTALLSTATE_UNKNOWN;
sz = 0; type = 0; rc = RegQueryValueExW( hkey, squished_pc, NULL, &type, NULL, &sz ); - if( rc != ERROR_SUCCESS ) - goto end; - if( type != REG_SZ ) - goto end; - - sz += sizeof(WCHAR); - path = msi_alloc( sz ); - if( !path ) - goto end; - - rc = RegQueryValueExW( hkey, squished_pc, NULL, NULL, (LPVOID) path, &sz ); - if( rc != ERROR_SUCCESS ) - goto end; + if( rc == ERROR_SUCCESS && type == REG_SZ ) + { + sz += sizeof(WCHAR); + path = msi_alloc( sz ); + if( path ) + { + path[0] = 0; + rc = RegQueryValueExW( hkey, squished_pc, NULL, NULL, (LPVOID) path, &sz ); + if( rc != ERROR_SUCCESS ) + { + msi_free( path ); + path = NULL; + } + } + } + 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]=='0') { FIXME("Registry entry.. check entry\n"); @@ -1081,28 +1037,63 @@ INSTALLSTATE WINAPI MsiGetComponentPathW } else { - /* PROBABLY a file */ if ( GetFileAttributesW(path) != INVALID_FILE_ATTRIBUTES ) rrc = INSTALLSTATE_LOCAL; else rrc = INSTALLSTATE_ABSENT; }
- if( pcchBuf ) - { - sz = sz / sizeof(WCHAR); - if( *pcchBuf >= sz ) - lstrcpyW( lpPathBuf, path ); - *pcchBuf = sz; - } + msi_strcpy_to_awstring( path, lpPathBuf, pcchBuf );
-end: - msi_free(path ); - RegCloseKey(hkey); + msi_free( path ); return rrc; }
/****************************************************************** + * 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)