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 rc;
|
||||
LPWSTR szwProduct= NULL;
|
||||
LPWSTR szwFeature= NULL;
|
||||
LPWSTR szwProduct = NULL, szwFeature= NULL;
|
||||
INSTALLSTATE rc = INSTALLSTATE_UNKNOWN;
|
||||
|
||||
if( szProduct )
|
||||
{
|
||||
szwProduct = strdupAtoW( szProduct );
|
||||
if( !szwProduct)
|
||||
return ERROR_OUTOFMEMORY;
|
||||
}
|
||||
szwProduct = strdupAtoW( szProduct );
|
||||
if ( szProduct && !szwProduct )
|
||||
goto end;
|
||||
|
||||
if( szFeature )
|
||||
{
|
||||
szwFeature = strdupAtoW( szFeature );
|
||||
if( !szwFeature)
|
||||
{
|
||||
msi_free( szwProduct);
|
||||
return ERROR_OUTOFMEMORY;
|
||||
}
|
||||
}
|
||||
szwFeature = strdupAtoW( szFeature );
|
||||
if ( szFeature && !szwFeature )
|
||||
goto end;
|
||||
|
||||
rc = MsiQueryFeatureStateW(szwProduct, szwFeature);
|
||||
|
||||
end:
|
||||
msi_free( szwProduct);
|
||||
msi_free( szwFeature);
|
||||
|
||||
|
@ -1114,12 +1105,19 @@ INSTALLSTATE WINAPI MsiQueryFeatureStateA(LPCSTR szProduct, LPCSTR szFeature)
|
|||
*/
|
||||
INSTALLSTATE WINAPI MsiQueryFeatureStateW(LPCWSTR szProduct, LPCWSTR szFeature)
|
||||
{
|
||||
WCHAR squishProduct[GUID_SIZE];
|
||||
UINT rc;
|
||||
DWORD sz = 0;
|
||||
HKEY hkey;
|
||||
|
||||
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);
|
||||
if (rc != ERROR_SUCCESS)
|
||||
return INSTALLSTATE_UNKNOWN;
|
||||
|
@ -1129,8 +1127,8 @@ INSTALLSTATE WINAPI MsiQueryFeatureStateW(LPCWSTR szProduct, LPCWSTR szFeature)
|
|||
|
||||
if (rc == ERROR_SUCCESS)
|
||||
return INSTALLSTATE_LOCAL;
|
||||
else
|
||||
return INSTALLSTATE_ABSENT;
|
||||
|
||||
return INSTALLSTATE_UNKNOWN;
|
||||
}
|
||||
|
||||
/******************************************************************
|
||||
|
@ -1414,18 +1412,23 @@ end:
|
|||
INSTALLSTATE WINAPI MsiUseFeatureExW( LPCWSTR szProduct, LPCWSTR szFeature,
|
||||
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);
|
||||
|
||||
/*
|
||||
* Polls all the components of the feature to find install state and then
|
||||
* writes:
|
||||
* Software\\Microsoft\\Windows\\CurrentVersion\\
|
||||
* Installer\\Products\\<squishguid>\\<feature>
|
||||
* "Usage"=dword:........
|
||||
*/
|
||||
state = MsiQueryFeatureStateW( szProduct, szFeature );
|
||||
|
||||
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
|
||||
db.ok
|
||||
format.ok
|
||||
msi.ok
|
||||
package.ok
|
||||
record.ok
|
||||
suminfo.ok
|
||||
|
|
|
@ -8,6 +8,7 @@ IMPORTS = msi kernel32
|
|||
CTESTS = \
|
||||
db.c \
|
||||
format.c \
|
||||
msi.c \
|
||||
package.c \
|
||||
record.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