Improve MsiUseFeatureEx and MsiGetFeatureState a little, add some
simple test cases.
This commit is contained in:
parent
1928ee8804
commit
94caa05d07
|
@ -1076,29 +1076,20 @@ end:
|
||||||
*/
|
*/
|
||||||
INSTALLSTATE WINAPI MsiQueryFeatureStateA(LPCSTR szProduct, LPCSTR szFeature)
|
INSTALLSTATE WINAPI MsiQueryFeatureStateA(LPCSTR szProduct, LPCSTR szFeature)
|
||||||
{
|
{
|
||||||
INSTALLSTATE rc;
|
LPWSTR szwProduct = NULL, szwFeature= NULL;
|
||||||
LPWSTR szwProduct= NULL;
|
INSTALLSTATE rc = INSTALLSTATE_UNKNOWN;
|
||||||
LPWSTR szwFeature= NULL;
|
|
||||||
|
|
||||||
if( szProduct )
|
szwProduct = strdupAtoW( szProduct );
|
||||||
{
|
if ( szProduct && !szwProduct )
|
||||||
szwProduct = strdupAtoW( szProduct );
|
goto end;
|
||||||
if( !szwProduct)
|
|
||||||
return ERROR_OUTOFMEMORY;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( szFeature )
|
szwFeature = strdupAtoW( szFeature );
|
||||||
{
|
if ( szFeature && !szwFeature )
|
||||||
szwFeature = strdupAtoW( szFeature );
|
goto end;
|
||||||
if( !szwFeature)
|
|
||||||
{
|
|
||||||
msi_free( szwProduct);
|
|
||||||
return ERROR_OUTOFMEMORY;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
rc = MsiQueryFeatureStateW(szwProduct, szwFeature);
|
rc = MsiQueryFeatureStateW(szwProduct, szwFeature);
|
||||||
|
|
||||||
|
end:
|
||||||
msi_free( szwProduct);
|
msi_free( szwProduct);
|
||||||
msi_free( szwFeature);
|
msi_free( szwFeature);
|
||||||
|
|
||||||
|
@ -1114,12 +1105,19 @@ INSTALLSTATE WINAPI MsiQueryFeatureStateA(LPCSTR szProduct, LPCSTR szFeature)
|
||||||
*/
|
*/
|
||||||
INSTALLSTATE WINAPI MsiQueryFeatureStateW(LPCWSTR szProduct, LPCWSTR szFeature)
|
INSTALLSTATE WINAPI MsiQueryFeatureStateW(LPCWSTR szProduct, LPCWSTR szFeature)
|
||||||
{
|
{
|
||||||
|
WCHAR squishProduct[GUID_SIZE];
|
||||||
UINT rc;
|
UINT rc;
|
||||||
DWORD sz = 0;
|
DWORD sz = 0;
|
||||||
HKEY hkey;
|
HKEY hkey;
|
||||||
|
|
||||||
TRACE("%s %s\n", debugstr_w(szProduct), debugstr_w(szFeature));
|
TRACE("%s %s\n", debugstr_w(szProduct), debugstr_w(szFeature));
|
||||||
|
|
||||||
|
if (!szProduct || !szFeature)
|
||||||
|
return INSTALLSTATE_INVALIDARG;
|
||||||
|
|
||||||
|
if (!squash_guid( szProduct, squishProduct ))
|
||||||
|
return INSTALLSTATE_INVALIDARG;
|
||||||
|
|
||||||
rc = MSIREG_OpenFeaturesKey(szProduct, &hkey, FALSE);
|
rc = MSIREG_OpenFeaturesKey(szProduct, &hkey, FALSE);
|
||||||
if (rc != ERROR_SUCCESS)
|
if (rc != ERROR_SUCCESS)
|
||||||
return INSTALLSTATE_UNKNOWN;
|
return INSTALLSTATE_UNKNOWN;
|
||||||
|
@ -1129,8 +1127,8 @@ INSTALLSTATE WINAPI MsiQueryFeatureStateW(LPCWSTR szProduct, LPCWSTR szFeature)
|
||||||
|
|
||||||
if (rc == ERROR_SUCCESS)
|
if (rc == ERROR_SUCCESS)
|
||||||
return INSTALLSTATE_LOCAL;
|
return INSTALLSTATE_LOCAL;
|
||||||
else
|
|
||||||
return INSTALLSTATE_ABSENT;
|
return INSTALLSTATE_UNKNOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************
|
/******************************************************************
|
||||||
|
@ -1414,18 +1412,23 @@ end:
|
||||||
INSTALLSTATE WINAPI MsiUseFeatureExW( LPCWSTR szProduct, LPCWSTR szFeature,
|
INSTALLSTATE WINAPI MsiUseFeatureExW( LPCWSTR szProduct, LPCWSTR szFeature,
|
||||||
DWORD dwInstallMode, DWORD dwReserved )
|
DWORD dwInstallMode, DWORD dwReserved )
|
||||||
{
|
{
|
||||||
FIXME("%s %s %li %li\n", debugstr_w(szProduct), debugstr_w(szFeature),
|
INSTALLSTATE state;
|
||||||
|
|
||||||
|
TRACE("%s %s %li %li\n", debugstr_w(szProduct), debugstr_w(szFeature),
|
||||||
dwInstallMode, dwReserved);
|
dwInstallMode, dwReserved);
|
||||||
|
|
||||||
/*
|
state = MsiQueryFeatureStateW( szProduct, szFeature );
|
||||||
* Polls all the components of the feature to find install state and then
|
|
||||||
* writes:
|
|
||||||
* Software\\Microsoft\\Windows\\CurrentVersion\\
|
|
||||||
* Installer\\Products\\<squishguid>\\<feature>
|
|
||||||
* "Usage"=dword:........
|
|
||||||
*/
|
|
||||||
|
|
||||||
return INSTALLSTATE_LOCAL;
|
if (dwReserved)
|
||||||
|
return INSTALLSTATE_INVALIDARG;
|
||||||
|
|
||||||
|
if (state == INSTALLSTATE_LOCAL && dwInstallMode != INSTALLMODE_NODETECTION)
|
||||||
|
{
|
||||||
|
FIXME("mark product %s feature %s as used\n",
|
||||||
|
debugstr_w(szProduct), debugstr_w(szFeature) );
|
||||||
|
}
|
||||||
|
|
||||||
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
Makefile
|
Makefile
|
||||||
db.ok
|
db.ok
|
||||||
format.ok
|
format.ok
|
||||||
|
msi.ok
|
||||||
package.ok
|
package.ok
|
||||||
record.ok
|
record.ok
|
||||||
suminfo.ok
|
suminfo.ok
|
||||||
|
|
|
@ -8,6 +8,7 @@ IMPORTS = msi kernel32
|
||||||
CTESTS = \
|
CTESTS = \
|
||||||
db.c \
|
db.c \
|
||||||
format.c \
|
format.c \
|
||||||
|
msi.c \
|
||||||
package.c \
|
package.c \
|
||||||
record.c \
|
record.c \
|
||||||
suminfo.c
|
suminfo.c
|
||||||
|
|
|
@ -0,0 +1,76 @@
|
||||||
|
/*
|
||||||
|
* tests for Microsoft Installer functionality
|
||||||
|
*
|
||||||
|
* Copyright 2005 Mike McCormack for CodeWeavers
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2.1 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <windows.h>
|
||||||
|
#include <msi.h>
|
||||||
|
#include <msiquery.h>
|
||||||
|
|
||||||
|
#include "wine/test.h"
|
||||||
|
|
||||||
|
typedef INSTALLSTATE (WINAPI *fnMsiUseFeatureExA)(LPCSTR, LPCSTR ,DWORD, DWORD );
|
||||||
|
fnMsiUseFeatureExA pMsiUseFeatureExA;
|
||||||
|
|
||||||
|
static void test_usefeature(void)
|
||||||
|
{
|
||||||
|
UINT r;
|
||||||
|
|
||||||
|
if (!pMsiUseFeatureExA)
|
||||||
|
return;
|
||||||
|
|
||||||
|
r = MsiQueryFeatureState(NULL,NULL);
|
||||||
|
ok( r == INSTALLSTATE_INVALIDARG, "wrong return val\n");
|
||||||
|
|
||||||
|
r = MsiQueryFeatureState("{9085040-6000-11d3-8cfe-0150048383c9}" ,NULL);
|
||||||
|
ok( r == INSTALLSTATE_INVALIDARG, "wrong return val\n");
|
||||||
|
|
||||||
|
r = MsiUseFeatureExA(NULL,NULL,0,0);
|
||||||
|
ok( r == INSTALLSTATE_INVALIDARG, "wrong return val\n");
|
||||||
|
|
||||||
|
r = MsiUseFeatureExA(NULL,
|
||||||
|
"WORDVIEWFiles", -2, 1 );
|
||||||
|
ok( r == INSTALLSTATE_INVALIDARG, "wrong return val\n");
|
||||||
|
|
||||||
|
r = MsiUseFeatureExA("{90850409-6000-11d3-8cfe-0150048383c9}",
|
||||||
|
NULL, -2, 0 );
|
||||||
|
ok( r == INSTALLSTATE_INVALIDARG, "wrong return val\n");
|
||||||
|
|
||||||
|
r = MsiUseFeatureExA("{9085040-6000-11d3-8cfe-0150048383c9}",
|
||||||
|
"WORDVIEWFiles", -2, 0 );
|
||||||
|
ok( r == INSTALLSTATE_INVALIDARG, "wrong return val\n");
|
||||||
|
|
||||||
|
r = MsiUseFeatureExA("{0085040-6000-11d3-8cfe-0150048383c9}",
|
||||||
|
"WORDVIEWFiles", -2, 0 );
|
||||||
|
ok( r == INSTALLSTATE_INVALIDARG, "wrong return val\n");
|
||||||
|
|
||||||
|
r = MsiUseFeatureExA("{90850409-6000-11d3-8cfe-0150048383c9}",
|
||||||
|
"WORDVIEWFiles", -2, 1 );
|
||||||
|
ok( r == INSTALLSTATE_INVALIDARG, "wrong return val\n");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
START_TEST(msi)
|
||||||
|
{
|
||||||
|
HMODULE hmod = GetModuleHandle("msi.dll");
|
||||||
|
pMsiUseFeatureExA = (fnMsiUseFeatureExA)
|
||||||
|
GetProcAddress(hmod, "MsiUseFeatureExA");
|
||||||
|
|
||||||
|
test_usefeature();
|
||||||
|
}
|
Loading…
Reference in New Issue