Feature #6613
openVT_RECORD, IRecordInfo Support in WIN32OLE
Description
WIN32OLE has no support for VT_RECORD VARIANTS. Python and Perl use the
functions GetRecordInfoFromTypeInfo and GetRecordInfoFromGuids to add
support for VT_RECORD and the IRecordInfo interface.
suggest having a class IRecordInfo and support for generating a Class
for the UDT to use this Record/Struct in ruby
The method starting on 1395 needs a case statement for VT_RECORD and a way to turn that into a IRECORD class
static void *
get_ptr_of_variant(VARIANT *pvar)
{
switch(V_VT(pvar)) {
case VT_UI1:
return &V_UI1(pvar);
break;
The IDL definitions for the methods are as follows
HRESULT GetRecordInfoFromTypeInfo(
__in ITypeInfo *pTypeInfo,
__out IRecordInfo **ppRecInfo
);
HRESULT GetRecordInfoFromGuids(
__in REFGUID rGuidTypeLib,
__in ULONG uVerMajor,
__in ULONG uVerMinor,
__in LCID lcid,
__in REFGUID rGuidTypeInfo,
__out IRecordInfo **ppRecInfo
);
here is the CTYPES definition for python that adds this support
class IRecordInfo(IUnknown):
# C:/vc98/include/OAIDL.H 5974
iid = GUID("{0000002F-0000-0000-C000-000000000046}")
def GetFieldNames(self, *args):
count = c_ulong()
self.__com_GetFieldNames(count, None)
array = (BSTR * count.value)()
self.__com_GetFieldNames(count, array)
result = array[:]
# XXX Should SysFreeString the array contents. How to?
return result
IRecordInfo. methods = [
COMMETHOD([], HRESULT, 'RecordInit',
(['in'], c_void_p, 'pvNew')),
COMMETHOD([], HRESULT, 'RecordClear',
(['in'], c_void_p, 'pvExisting')),
COMMETHOD([], HRESULT, 'RecordCopy',
(['in'], c_void_p, 'pvExisting'),
(['in'], c_void_p, 'pvNew')),
COMMETHOD([], HRESULT, 'GetGuid',
(['out'], POINTER(GUID), 'pguid')),
COMMETHOD([], HRESULT, 'GetName',
(['out'], POINTER(BSTR), 'pbstrName')),
COMMETHOD([], HRESULT, 'GetSize',
(['out'], POINTER(c_ulong), 'pcbSize')),
COMMETHOD([], HRESULT, 'GetTypeInfo',
(['out'], POINTER(POINTER(ITypeInfo)), 'ppTypeInfo')),
COMMETHOD([], HRESULT, 'GetField',
(['in'], c_void_p, 'pvData'),
(['in'], c_wchar_p, 'szFieldName'),
(['out'], POINTER(VARIANT), 'pvarField')),
COMMETHOD([], HRESULT, 'GetFieldNoCopy',
(['in'], c_void_p, 'pvData'),
(['in'], c_wchar_p, 'szFieldName'),
(['out'], POINTER(VARIANT), 'pvarField'),
(['out'], POINTER(c_void_p), 'ppvDataCArray')),
COMMETHOD([], HRESULT, 'PutField',
(['in'], c_ulong, 'wFlags'),
(['in'], c_void_p, 'pvData'),
(['in'], c_wchar_p, 'szFieldName'),
(['in'], POINTER(VARIANT), 'pvarField')),
COMMETHOD([], HRESULT, 'PutFieldNoCopy',
(['in'], c_ulong, 'wFlags'),
(['in'], c_void_p, 'pvData'),
(['in'], c_wchar_p, 'szFieldName'),
(['in'], POINTER(VARIANT), 'pvarField')),
COMMETHOD([], HRESULT, 'GetFieldNames',
(['in', 'out'], POINTER(c_ulong), 'pcNames'),
(['in'], POINTER(BSTR), 'rgBstrNames')),
COMMETHOD([], BOOL, 'IsMatchingType',
(['in'], POINTER(IRecordInfo))),
COMMETHOD([], HRESULT, 'RecordCreate'),
COMMETHOD([], HRESULT, 'RecordCreateCopy',
(['in'], c_void_p, 'pvSource'),
(['out'], POINTER(c_void_p), 'ppvDest')),
COMMETHOD([], HRESULT, 'RecordDestroy',
(['in'], c_void_p, 'pvRecord'))]
################################################################
functions¶
_oleaut32 = oledll.oleaut32
def GetRecordInfoFromTypeInfo(tinfo):
"Return an IRecordInfo pointer to the UDT described in tinfo"
ri = POINTER(IRecordInfo)()
_oleaut32.GetRecordInfoFromTypeInfo(tinfo, byref(ri))
return ri
def GetRecordInfoFromGuids(rGuidTypeLib, verMajor, verMinor, lcid,
rGuidTypeInfo):
ri = POINTER(IRecordInfo)()
_oleaut32.GetRecordInfoFromGuids(byref(GUID(rGuidTypeLib)),
verMajor, verMinor, lcid,
byref(GUID(rGuidTypeInfo)),
byref(ri))
return ri
Updated by nahi (Hiroshi Nakamura) over 12 years ago
- Category set to ext
- Status changed from Open to Assigned
- Assignee set to suke (Masaki Suketa)
Suketa-san, would you please comment to it?
Updated by dsisnero (Dominic Sisneros) almost 11 years ago
Still no progress on this?? I wish I knew C better
Updated by suke (Masaki Suketa) over 10 years ago
Sorry for waiting too long. I had implemented VT_RECORD / IRecordInterface features.
Try WIN32OLE_RECORD class in ruby-trunk (2.2.0dev revision 47020 or later).