wbemprox: Implement IWbemClassObject::Get.

This commit is contained in:
Hans Leidekker 2012-06-18 09:31:29 +02:00 committed by Alexandre Julliard
parent bb80d7db9a
commit 92e9986628
4 changed files with 57 additions and 3 deletions

View File

@ -1,5 +1,5 @@
MODULE = wbemprox.dll
IMPORTS = ole32 advapi32
IMPORTS = oleaut32 ole32 advapi32
C_SRCS = \
builtin.c \

View File

@ -274,8 +274,18 @@ static HRESULT WINAPI class_object_Get(
CIMTYPE *pType,
LONG *plFlavor )
{
FIXME("%p, %s, %08x, %p, %p, %p\n", iface, debugstr_w(wszName), lFlags, pVal, pType, plFlavor);
return E_NOTIMPL;
struct class_object *co = impl_from_IWbemClassObject( iface );
struct enum_class_object *ec = impl_from_IEnumWbemClassObject( co->iter );
struct view *view = ec->query->view;
TRACE("%p, %s, %08x, %p, %p, %p\n", iface, debugstr_w(wszName), lFlags, pVal, pType, plFlavor);
if (plFlavor)
{
FIXME("flavor parameter not supported\n");
*plFlavor = 0;
}
return get_propval( view, co->index, wszName, pVal, pType );
}
static HRESULT WINAPI class_object_Put(

View File

@ -347,3 +347,45 @@ done:
if (hr != S_OK) free_query( query );
return hr;
}
static BOOL is_selected_prop( const struct view *view, const WCHAR *name )
{
const struct property *prop = view->proplist;
if (!prop) return TRUE;
while (prop)
{
if (!strcmpiW( prop->name, name )) return TRUE;
prop = prop->next;
}
return FALSE;
}
HRESULT get_propval( const struct view *view, UINT index, const WCHAR *name, VARIANT *ret, CIMTYPE *type )
{
HRESULT hr;
UINT column, row = view->result[index];
INT_PTR val;
if (!is_selected_prop( view, name )) return WBEM_E_NOT_FOUND;
hr = get_column_index( view->table, name, &column );
if (hr != S_OK) return WBEM_E_NOT_FOUND;
hr = get_value( view->table, row, column, &val );
if (hr != S_OK) return hr;
switch (view->table->columns[column].type)
{
case CIM_STRING:
case CIM_DATETIME:
V_VT( ret ) = VT_BSTR;
V_BSTR( ret ) = SysAllocString( (const WCHAR *)val );
break;
default:
ERR("unhandled column type %u\n", view->table->columns[column].type);
return WBEM_E_FAILED;
}
if (type) *type = view->table->columns[column].type;
return S_OK;
}

View File

@ -111,6 +111,8 @@ HRESULT create_view( const struct property *, const WCHAR *, const struct expr *
struct view ** ) DECLSPEC_HIDDEN;
void destroy_view( struct view * ) DECLSPEC_HIDDEN;
struct table *get_table( const WCHAR * ) DECLSPEC_HIDDEN;
HRESULT get_propval( const struct view *, UINT, const WCHAR *, VARIANT *,
CIMTYPE * ) DECLSPEC_HIDDEN;
HRESULT WbemLocator_create(IUnknown *, LPVOID *) DECLSPEC_HIDDEN;
HRESULT WbemServices_create(IUnknown *, LPVOID *) DECLSPEC_HIDDEN;