systeminfo.c 4.33 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
/*
 * IAutomaticUpdates implementation
 *
 * Copyright 2008 Hans Leidekker
 * Copyright 2011 Bernhard Loos
 *
 * 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
 */

#define COBJMACROS

#include <stdarg.h>

#include "windef.h"
#include "winbase.h"
#include "winuser.h"
#include "ole2.h"
#include "wuapi.h"
31
#include "wuapi_private.h"
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145

#include "wine/debug.h"

WINE_DEFAULT_DEBUG_CHANNEL(wuapi);

typedef struct _systeminfo
{
    ISystemInformation ISystemInformation_iface;
    LONG refs;
} systeminfo;

static inline systeminfo *impl_from_ISystemInformation(ISystemInformation *iface)
{
    return CONTAINING_RECORD(iface, systeminfo, ISystemInformation_iface);
}

static ULONG WINAPI systeminfo_AddRef(ISystemInformation *iface)
{
    systeminfo *This = impl_from_ISystemInformation(iface);
    return InterlockedIncrement(&This->refs);
}

static ULONG WINAPI systeminfo_Release(ISystemInformation *iface)
{
    systeminfo *This = impl_from_ISystemInformation(iface);
    LONG refs = InterlockedDecrement(&This->refs);
    if (!refs)
    {
        TRACE("destroying %p\n", This);
        HeapFree(GetProcessHeap(), 0, This);
    }
    return refs;
}

static HRESULT WINAPI systeminfo_QueryInterface(ISystemInformation *iface,
                    REFIID riid, void **ppvObject)
{
    systeminfo *This = impl_from_ISystemInformation(iface);

    TRACE("%p %s %p\n", This, debugstr_guid(riid), ppvObject);

    if (IsEqualGUID(riid, &IID_ISystemInformation) ||
        IsEqualGUID(riid, &IID_IDispatch) ||
        IsEqualGUID(riid, &IID_IUnknown))
    {
        *ppvObject = iface;
    }
    else
    {
        FIXME("interface %s not implemented\n", debugstr_guid(riid));
        return E_NOINTERFACE;
    }
    ISystemInformation_AddRef(iface);
    return S_OK;
}

static HRESULT WINAPI systeminfo_GetTypeInfoCount(ISystemInformation *iface,
                    UINT *pctinfo )
{
    FIXME("\n");
    return E_NOTIMPL;
}

static HRESULT WINAPI systeminfo_GetTypeInfo(ISystemInformation *iface,
                    UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
{
    FIXME("\n");
    return E_NOTIMPL;
}

static HRESULT WINAPI systeminfo_GetIDsOfNames(ISystemInformation *iface,
                    REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid,
                    DISPID *rgDispId)
{
    FIXME("\n");
    return E_NOTIMPL;
}

static HRESULT WINAPI systeminfo_Invoke(ISystemInformation *iface,
                    DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags,
                    DISPPARAMS *pDispParams, VARIANT *pVarResult,
                    EXCEPINFO *pExcepInfo, UINT *puArgErr )
{
    FIXME("\n");
    return E_NOTIMPL;
}

static HRESULT WINAPI systeminfo_get_OemHardwareSupportLink(ISystemInformation *iface,
                                BSTR *retval)
{
    FIXME("\n");
    return E_NOTIMPL;
}

static HRESULT WINAPI systeminfo_get_RebootRequired(ISystemInformation *iface,
                                VARIANT_BOOL *retval)
{
    *retval = VARIANT_FALSE;
    return S_OK;
}

static const struct ISystemInformationVtbl systeminfo_vtbl =
{
    systeminfo_QueryInterface,
    systeminfo_AddRef,
    systeminfo_Release,
    systeminfo_GetTypeInfoCount,
    systeminfo_GetTypeInfo,
    systeminfo_GetIDsOfNames,
    systeminfo_Invoke,
    systeminfo_get_OemHardwareSupportLink,
    systeminfo_get_RebootRequired
};

146
HRESULT SystemInformation_create(LPVOID *ppObj)
147 148 149
{
    systeminfo *info;

150
    TRACE("(%p)\n", ppObj);
151 152 153 154 155 156 157 158 159 160 161 162 163

    info = HeapAlloc(GetProcessHeap(), 0, sizeof(*info));
    if (!info)
        return E_OUTOFMEMORY;

    info->ISystemInformation_iface.lpVtbl = &systeminfo_vtbl;
    info->refs = 1;

    *ppObj = &info->ISystemInformation_iface;

    TRACE("returning iface %p\n", *ppObj);
    return S_OK;
}