#include "winbase.h"
#include "winuser.h"
#include "winreg.h"
-#include "winver.h"
#include "winternl.h"
#include "winnls.h"
#include "setupapi.h"
#include "advpub.h"
+#include "ole2.h"
#include "wine/debug.h"
#include "wine/unicode.h"
#include "advpack_private.h"
#define SPAPI_ERROR 0xE0000000L
#define SPAPI_PREFIX 0x800F0000L
#define SPAPI_MASK 0xFFFFL
-#define HRESULT_FROM_SPAPI(x) ((x & SPAPI_MASK) | SPAPI_PREFIX)
+#define HRESULT_FROM_SPAPI(x) ((HRESULT)((x & SPAPI_MASK) | SPAPI_PREFIX))
#define ADV_HRESULT(x) ((x & SPAPI_ERROR) ? HRESULT_FROM_SPAPI(x) : HRESULT_FROM_WIN32(x))
BOOL need_reboot;
} ADVInfo;
-typedef HRESULT (*iterate_fields_func)(HINF hinf, PCWSTR field, void *arg);
+typedef HRESULT (*iterate_fields_func)(HINF hinf, PCWSTR field, const void *arg);
/* Advanced INF commands */
static const WCHAR CheckAdminRights[] = {
};
/* Advanced INF callbacks */
-static HRESULT del_dirs_callback(HINF hinf, PCWSTR field, void *arg)
+static HRESULT del_dirs_callback(HINF hinf, PCWSTR field, const void *arg)
{
INFCONTEXT context;
HRESULT hr = S_OK;
MAX_INF_STRING_LENGTH, &size))
continue;
- if (DelNodeW(directory, ADN_DEL_IF_EMPTY))
+ if (DelNodeW(directory, ADN_DEL_IF_EMPTY) != S_OK)
hr = E_FAIL;
}
return hr;
}
-static HRESULT per_user_install_callback(HINF hinf, PCWSTR field, void *arg)
+static HRESULT per_user_install_callback(HINF hinf, PCWSTR field, const void *arg)
{
PERUSERSECTIONW per_user;
INFCONTEXT context;
return SetPerUserSecValuesW(&per_user);
}
-static HRESULT register_ocxs_callback(HINF hinf, PCWSTR field, void *arg)
+static HRESULT register_ocxs_callback(HINF hinf, PCWSTR field, const void *arg)
{
HMODULE hm;
INFCONTEXT context;
continue;
hm = LoadLibraryExW(buffer, NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
- if (!hm)
- continue;
+ if (hm)
+ {
+ if (do_ocx_reg(hm, TRUE) != S_OK)
+ hr = E_FAIL;
- if (do_ocx_reg(hm, TRUE))
+ FreeLibrary(hm);
+ }
+ else
hr = E_FAIL;
- FreeLibrary(hm);
+ if (FAILED(hr))
+ {
+ /* FIXME: display a message box */
+ break;
+ }
}
return hr;
}
-static HRESULT run_setup_commands_callback(HINF hinf, PCWSTR field, void *arg)
+static HRESULT run_setup_commands_callback(HINF hinf, PCWSTR field, const void *arg)
{
- ADVInfo *info = (ADVInfo *)arg;
+ const ADVInfo *info = (const ADVInfo *)arg;
INFCONTEXT context;
HRESULT hr = S_OK;
DWORD size;
MAX_INF_STRING_LENGTH, &size))
continue;
- if (launch_exe(buffer, info->working_dir, NULL))
+ if (launch_exe(buffer, info->working_dir, NULL) != S_OK)
hr = E_FAIL;
}
return hr;
}
-static HRESULT check_admin_rights(ADVInfo *info)
+static HRESULT check_admin_rights(const ADVInfo *info)
{
INT check;
INFCONTEXT context;
}
/* performs a setupapi-level install of the INF file */
-static HRESULT spapi_install(ADVInfo *info)
+static HRESULT spapi_install(const ADVInfo *info)
{
BOOL ret;
HRESULT res;
if (hr != S_OK)
return hr;
+ OleInitialize(NULL);
hr = iterate_section_fields(info->hinf, info->install_sec,
RegisterOCXs, register_ocxs_callback, NULL);
+ OleUninitialize();
if (hr != S_OK)
return hr;
}
/* release the install instance information */
-static void install_release(ADVInfo *info)
+static void install_release(const ADVInfo *info)
{
- if (info->hinf && info->hinf != INVALID_HANDLE_VALUE)
- SetupCloseInfFile(info->hinf);
+ SetupCloseInfFile(info->hinf);
HeapFree(GetProcessHeap(), 0, info->inf_path);
HeapFree(GetProcessHeap(), 0, info->inf_filename);