Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/msi/install.c | 23 ++++------------------- dlls/msi/package.c | 5 ++--- dlls/msi/tests/custom.c | 19 +++++++++++++++++++ dlls/msi/winemsi.idl | 2 +- 4 files changed, 26 insertions(+), 23 deletions(-)
diff --git a/dlls/msi/install.c b/dlls/msi/install.c index b19b647..63ffbfe 100644 --- a/dlls/msi/install.c +++ b/dlls/msi/install.c @@ -1313,33 +1313,18 @@ UINT WINAPI MsiSetComponentStateW(MSIHANDLE hInstall, LPCWSTR szComponent, MSIPACKAGE* package; UINT ret;
+ if (!szComponent) + return ERROR_UNKNOWN_COMPONENT; + package = msihandle2msiinfo(hInstall, MSIHANDLETYPE_PACKAGE); if (!package) { MSIHANDLE remote; - HRESULT hr; - BSTR component;
if (!(remote = msi_get_remote(hInstall))) return ERROR_INVALID_HANDLE;
- component = SysAllocString(szComponent); - if (!component) - return ERROR_OUTOFMEMORY; - - hr = remote_SetComponentState(remote, component, iState); - - SysFreeString(component); - - if (FAILED(hr)) - { - if (HRESULT_FACILITY(hr) == FACILITY_WIN32) - return HRESULT_CODE(hr); - - return ERROR_FUNCTION_FAILED; - } - - return ERROR_SUCCESS; + return remote_SetComponentState(remote, szComponent, iState); }
ret = MSI_SetComponentStateW(package, szComponent, iState); diff --git a/dlls/msi/package.c b/dlls/msi/package.c index 18b8601..b1b2cb4 100644 --- a/dlls/msi/package.c +++ b/dlls/msi/package.c @@ -2540,10 +2540,9 @@ UINT __cdecl remote_GetComponentState(MSIHANDLE hinst, LPCWSTR component, return MsiGetComponentStateW(hinst, component, installed, action); }
-HRESULT __cdecl remote_SetComponentState(MSIHANDLE hinst, BSTR component, INSTALLSTATE state) +UINT __cdecl remote_SetComponentState(MSIHANDLE hinst, LPCWSTR component, INSTALLSTATE state) { - UINT r = MsiSetComponentStateW(hinst, component, state); - return HRESULT_FROM_WIN32(r); + return MsiSetComponentStateW(hinst, component, state); }
HRESULT __cdecl remote_GetLanguage(MSIHANDLE hinst, LANGID *language) diff --git a/dlls/msi/tests/custom.c b/dlls/msi/tests/custom.c index b2c9352..2f9ba5d 100644 --- a/dlls/msi/tests/custom.c +++ b/dlls/msi/tests/custom.c @@ -719,6 +719,25 @@ static void test_feature_states(MSIHANDLE hinst) ok(hinst, !r, "got %u\n", r); ok(hinst, state == INSTALLSTATE_UNKNOWN, "got state %d\n", state); ok(hinst, action == INSTALLSTATE_LOCAL, "got action %d\n", action); + + r = MsiSetComponentStateA(hinst, NULL, INSTALLSTATE_ABSENT); + ok(hinst, r == ERROR_UNKNOWN_COMPONENT, "got %u\n", r); + + r = MsiSetComponentStateA(hinst, "One", INSTALLSTATE_SOURCE); + ok(hinst, !r, "got %u\n", r); + + r = MsiGetComponentStateA(hinst, "One", &state, &action); + ok(hinst, !r, "got %u\n", r); + ok(hinst, state == INSTALLSTATE_ABSENT, "got state %d\n", state); + ok(hinst, action == INSTALLSTATE_SOURCE, "got action %d\n", action); + + r = MsiSetComponentStateA(hinst, "One", INSTALLSTATE_LOCAL); + ok(hinst, !r, "got %u\n", r); + + r = MsiGetComponentStateA(hinst, "One", &state, &action); + ok(hinst, !r, "got %u\n", r); + ok(hinst, state == INSTALLSTATE_ABSENT, "got state %d\n", state); + ok(hinst, action == INSTALLSTATE_LOCAL, "got action %d\n", action); }
/* Main test. Anything that doesn't depend on a specific install configuration diff --git a/dlls/msi/winemsi.idl b/dlls/msi/winemsi.idl index 5996487..132f140 100644 --- a/dlls/msi/winemsi.idl +++ b/dlls/msi/winemsi.idl @@ -84,7 +84,7 @@ interface IWineMsiRemote UINT remote_GetFeatureState( [in] MSIHANDLE hinst, [in, string] LPCWSTR feature, [out] INSTALLSTATE *installed, [out] INSTALLSTATE *action ); UINT remote_SetFeatureState( [in] MSIHANDLE hinst, [in, string] LPCWSTR feature, [in] INSTALLSTATE state ); UINT remote_GetComponentState( [in] MSIHANDLE hinst, [in, string] LPCWSTR component, [out] INSTALLSTATE *installed, [out] INSTALLSTATE *action ); - HRESULT remote_SetComponentState( [in] MSIHANDLE hinst, [in] BSTR component, [in] INSTALLSTATE state ); + UINT remote_SetComponentState( [in] MSIHANDLE hinst, [in, string] LPCWSTR component, [in] INSTALLSTATE state ); HRESULT remote_GetLanguage( [in] MSIHANDLE hinst, [out] LANGID *language ); HRESULT remote_SetInstallLevel( [in] MSIHANDLE hinst, [in] int level ); HRESULT remote_FormatRecord( [in] MSIHANDLE hinst, [in] MSIHANDLE record, [out] BSTR *value );