Ruby 2.7.0p0(2019-12-25revision647ee6f091eafcce70ffb75ddf7e121e192ab217)

Data Structures | Macros | Typedefs | Functions | Variables
win32ole.c File Reference
`#include "win32ole.h"`

Go to the source code of this file.

## Data Structures
struct | oleparam
struct | _Win32OLEIDispatch
struct | myCPINFOEX

## Macros
#define | WIN32OLE_VERSION "1.8.8"
#define | g_ole_initialized (TlsGetValue(g_ole_initialized_key)!=0)
#define | g_ole_initialized_init() (g_ole_initialized_key = TlsAlloc())
#define | g_ole_initialized_set(val) TlsSetValue(g_ole_initialized_key, (void*)(val))
#define | pIMultiLanguage NULL /* dummy */
#define | ENC_MACHING_CP(enc, encname, cp) if(strcasecmp(rb_enc_name((enc)),(encname)) == 0) return cp
#define | load_conv_function51932() failed_load_conv51932()
#define | need_conv_function51932() (failed_load_conv51932(), 0)
#define | conv_51932(cp) ((cp) == 51932 && need_conv_function51932())
#define | ole_wc2mb_conv(pw, pm, size) WideCharToMultiByte(cWIN32OLE_cp, 0, (pw), -1, (pm), (size), NULL, NULL)

## Typedefs
typedef IUnknown | DWORD
typedef IUnknown COSERVERINFO MULTI_QI *typedef | HWND(WINAPI FNHTMLHELP) (HWND hwndCaller
typedef IUnknown COSERVERINFO MULTI_QI *typedef LPCSTR | pszFile
typedef IUnknown COSERVERINFO MULTI_QI *typedef LPCSTR UINT | uCommand
typedef IUnknown COSERVERINFO MULTI_QI *typedef LPCSTR UINT DWORD | dwData
typedef BOOL() | FNENUMSYSEMCODEPAGES(CODEPAGE_ENUMPROC, DWORD)
typedef struct _Win32OLEIDispatch | Win32OLEIDispatch

## Functions
typedef | HRESULT (STDAPICALLTYPE FNCOCREATEINSTANCEEX)(REFCLSID
| NORETURN (static void failed_load_conv51932(void))
| free (psz)
| if ((ID)(DISPID) nameid !=nameid)
BOOL | ole_initialized (void)
char * | ole_wc2mb (LPWSTR pw)
void | ole_uninitialize (void)
void | ole_initialize (void)
struct oledata * | oledata_get_struct (VALUE ole)
LPWSTR | ole_vstr2wc (VALUE vstr)
VALUE | ole_wc2vstr (LPWSTR pw, BOOL isfree)
void | ole_val2variant_ex (VALUE val, VARIANT *var, VARTYPE vt)
VOID * | val2variant_ptr (VALUE val, VARIANT *var, VARTYPE vt)
HRESULT | ole_val_ary2variant_ary (VALUE val, VARIANT *var, VARTYPE vt)
void | ole_val2variant (VALUE val, VARIANT *var)
void | ole_val2variant2 (VALUE val, VARIANT *var)
VALUE | make_inspect (const char *class_name, VALUE detail)
VALUE | default_inspect (VALUE self, const char *class_name)
VALUE | ole_variant2val (VARIANT *pvar)
LONG | reg_open_key (HKEY hkey, const char *name, HKEY *phkey)
LONG | reg_open_vkey (HKEY hkey, VALUE key, HKEY *phkey)
VALUE | reg_enum_key (HKEY hkey, DWORD i)
VALUE | reg_get_val (HKEY hkey, const char *subkey)
VALUE | reg_get_val2 (HKEY hkey, const char *subkey)
HRESULT | ole_docinfo_from_type (ITypeInfo *pTypeInfo, BSTR *name, BSTR *helpstr, DWORD *helpcontext, BSTR *helpfile)
VALUE | ole_typedesc2val (ITypeInfo *pTypeInfo, TYPEDESC *pTypeDesc, VALUE typedetails)
HRESULT | typelib_from_val (VALUE obj, ITypeLib **pTypeLib)
void | Init_win32ole (void)

## Variables
VALUE | cWIN32OLE
static REFIID | riid
static REFIID void __RPC_FAR *__RPC_FAR * | ppvObject
static UINT __RPC_FAR * | pctinfo
static UINT | iTInfo
static UINT LCID | lcid
static UINT LCID ITypeInfo __RPC_FAR *__RPC_FAR * | ppTInfo
static REFIID LPOLESTR __RPC_FAR * | rgszNames
static REFIID LPOLESTR __RPC_FAR UINT | cNames
static REFIID LPOLESTR __RPC_FAR UINT LCID DISPID __RPC_FAR * | rgDispId
static DISPID | dispIdMember
static DISPID REFIID LCID WORD | wFlags
static DISPID REFIID LCID WORD DISPPARAMS __RPC_FAR * | pDispParams
static DISPID REFIID LCID WORD DISPPARAMS __RPC_FAR VARIANT __RPC_FAR * | pVarResult
static DISPID REFIID LCID WORD DISPPARAMS __RPC_FAR VARIANT __RPC_FAR EXCEPINFO __RPC_FAR * | pExcepInfo
static DISPID REFIID LCID WORD DISPPARAMS __RPC_FAR VARIANT __RPC_FAR EXCEPINFO __RPC_FAR UINT __RPC_FAR * | puArgErr
static DWORD | dwCallType
static DWORD HTASK | threadIDCaller
static DWORD HTASK DWORD | dwTickCount
static DWORD HTASK DWORD LPINTERFACEINFO | lpInterfaceInfo
static HTASK | threadIDCallee
static HTASK DWORD DWORD | dwRejectType
static HTASK DWORD DWORD | dwPendingType
ID | nameid = rb_check_id_cstr(psz, (long)strlen(psz), cWIN32OLE_enc)

## Macro Definition Documentation

## ◆ conv_51932

#define conv_51932 | ( |  | cp | ) | ((cp) == 51932 && need_conv_function51932())

Definition at line 588 of file win32ole.c.

## ◆ ENC_MACHING_CP

#define ENC_MACHING_CP | ( |  | enc,
|  |  | encname,
|  |  | cp
| ) |  | if(strcasecmp(rb_enc_name((enc)),(encname)) == 0) return cp

Definition at line 489 of file win32ole.c.

## ◆ g_ole_initialized

#define g_ole_initialized (TlsGetValue(g_ole_initialized_key)!=0)

Definition at line 46 of file win32ole.c.

## ◆ g_ole_initialized_init

#define g_ole_initialized_init | ( |  | ) | (g_ole_initialized_key = TlsAlloc())

Definition at line 47 of file win32ole.c.

## ◆ g_ole_initialized_set

#define g_ole_initialized_set | ( |  | val | ) | TlsSetValue(g_ole_initialized_key, (void*)(val))

Definition at line 48 of file win32ole.c.

## ◆ load_conv_function51932

#define load_conv_function51932 | ( |  | ) | failed_load_conv51932()

Definition at line 584 of file win32ole.c.

## ◆ need_conv_function51932

#define need_conv_function51932 | ( |  | ) | (failed_load_conv51932(), 0)

Definition at line 585 of file win32ole.c.

## ◆ ole_wc2mb_conv

#define ole_wc2mb_conv | ( |  | pw,
|  |  | pm,
|  |  | size
| ) |  | WideCharToMultiByte(cWIN32OLE_cp, 0, (pw), -1, (pm), (size), NULL, NULL)

Definition at line 713 of file win32ole.c.

## ◆ pIMultiLanguage

#define pIMultiLanguage NULL /* dummy */

Definition at line 75 of file win32ole.c.

## ◆ WIN32OLE_VERSION

#define WIN32OLE_VERSION "1.8.8"

Definition at line 30 of file win32ole.c.

## Typedef Documentation

## ◆ dwData

typedef IUnknown COSERVERINFO MULTI_QI* typedef LPCSTR UINT DWORD dwData

Definition at line 36 of file win32ole.c.

## ◆ DWORD

static DWORD

Definition at line 33 of file win32ole.c.

## ◆ FNENUMSYSEMCODEPAGES

typedef BOOL() FNENUMSYSEMCODEPAGES(CODEPAGE_ENUMPROC, DWORD)

Definition at line 37 of file win32ole.c.

## ◆ HWND

typedef IUnknown COSERVERINFO MULTI_QI* typedef HWND(WINAPI FNHTMLHELP)(HWND hwndCaller

Definition at line 35 of file win32ole.c.

## ◆ pszFile

typedef IUnknown COSERVERINFO MULTI_QI* typedef LPCSTR pszFile

Definition at line 35 of file win32ole.c.

## ◆ uCommand

typedef IUnknown COSERVERINFO MULTI_QI* typedef LPCSTR UINT uCommand

Definition at line 36 of file win32ole.c.

## ◆ Win32OLEIDispatch

typedef struct _Win32OLEIDispatch Win32OLEIDispatch

## Function Documentation

## ◆ default_inspect()

VALUE default_inspect | ( | VALUE | self,
|  | const char * | class_name
| ) |  |

Definition at line 1345 of file win32ole.c.

References make_inspect(), rb_funcall, and rb_intern.

## ◆ free()

free | ( | psz |  | ) |

Referenced by ole_variant2val(), and reg_get_val().

## ◆ HRESULT()

typedef HRESULT | ( | STDAPICALLTYPE | FNCOCREATEINSTANCEEX | ) |

Referenced by EVENTSINK_Invoke(), ole_docinfo_from_type(), ole_initialize(), ole_methods_from_typeinfo(), ole_type_from_itypeinfo(), ole_typelib_from_itypeinfo(), ole_val_ary2variant_ary(), ole_variant2val(), olerecord_set_ivar(), typelib_from_val(), and val2variant_ptr().

## ◆ if()

if | ( | (ID)(DISPID) nameid ! | = `nameid` | ) |

Definition at line 357 of file win32ole.c.

Referenced by ffi_prep_cif_machdep(), ffi_prep_closure_loc(), onig_foreach_name(), onig_memsize(), onig_number_of_names(), onig_renumber_name_table(), rb_iseq_insns_info_encode_positions(), rb_iseq_mark_insn_storage(), rb_method_definition_set(), rb_thread_call_with_gvl(), and VpSqrt().

## ◆ Init_win32ole()

void Init_win32ole | ( | void |  | ) |

Definition at line 3967 of file win32ole.c.

References cWIN32OLE_lcid, and g_ole_initialized_init.

## ◆ make_inspect()

VALUE make_inspect | ( | const char * | class_name,
|  | VALUE | detail
| ) |  |

Definition at line 1333 of file win32ole.c.

References rb_str_cat2, rb_str_concat(), rb_str_new2, and str.

Referenced by default_inspect().

## ◆ NORETURN()

NORETURN | ( | static void | failed_load_conv51932void | ) |

## ◆ ole_docinfo_from_type()

HRESULT ole_docinfo_from_type | ( | ITypeInfo * | pTypeInfo,
|  | BSTR * | name,
|  | BSTR * | helpstr,
|  | DWORD * | helpcontext,
|  | BSTR * | helpfile
| ) |  |

Definition at line 3647 of file win32ole.c.

References HRESULT(), i, name, and OLE_RELEASE.

## ◆ ole_initialize()

void ole_initialize | ( | void |  | ) |

Definition at line 813 of file win32ole.c.

References HRESULT().

## ◆ ole_initialized()

BOOL ole_initialized | ( | void |  | ) |

Definition at line 395 of file win32ole.c.

References g_ole_initialized.

## ◆ ole_typedesc2val()

VALUE ole_typedesc2val | ( | ITypeInfo * | pTypeInfo,
|  | TYPEDESC * | pTypeDesc,
|  | VALUE | typedetails
| ) |  |

Definition at line 3708 of file win32ole.c.

References Qnil, rb_ary_push(), rb_str_new2, and str.

## ◆ ole_uninitialize()

void ole_uninitialize | ( | void |  | ) |

Definition at line 799 of file win32ole.c.

References FALSE, g_ole_initialized, and g_ole_initialized_set.

## ◆ ole_val2variant()

void ole_val2variant | ( | VALUE | val,
|  | VARIANT * | var
| ) |  |

Definition at line 1249 of file win32ole.c.

References cWIN32OLE, cWIN32OLE_RECORD, cWIN32OLE_VARIANT, NULL, OLE_ADDREF, ole_rec2variant(), ole_variant2variant(), oledata_get_struct(), oledata::pDispatch, rb_cTime, and rb_obj_is_kind_of().

## ◆ ole_val2variant2()

void ole_val2variant2 | ( | VALUE | val,
|  | VARIANT * | var
| ) |  |

Definition at line 1325 of file win32ole.c.

Referenced by ole_val2variant_ex().

## ◆ ole_val2variant_ex()

void ole_val2variant_ex | ( | VALUE | val,
|  | VARIANT * | var,
|  | VARTYPE | vt
| ) |  |

Definition at line 982 of file win32ole.c.

References NULL, NUM2I8, NUM2UI8, ole_val2variant2(), and Qnil.

Referenced by val2variant_ptr().

## ◆ ole_val_ary2variant_ary()

HRESULT ole_val_ary2variant_ary | ( | VALUE | val,
|  | VARIANT * | var,
|  | VARTYPE | vt
| ) |  |

Definition at line 1187 of file win32ole.c.

References Check_Type, HRESULT(), i, NULL, and T_ARRAY.

## ◆ ole_variant2val()

VALUE ole_variant2val | ( | VARIANT * | pvar | ) |

Definition at line 1418 of file win32ole.c.

References ALLOC_N, free(), HRESULT(), i, obj, Qnil, rb_ary_new(), rb_eRuntimeError, and rb_raise().

## ◆ ole_vstr2wc()

LPWSTR ole_vstr2wc | ( | VALUE | vstr | ) |

Definition at line 865 of file win32ole.c.

References DATA_PTR, and rb_encoding.

## ◆ ole_wc2mb()

char* ole_wc2mb | ( | LPWSTR | pw | ) |

Definition at line 743 of file win32ole.c.

## ◆ ole_wc2vstr()

VALUE ole_wc2vstr | ( | LPWSTR | pw,
|  | BOOL | isfree
| ) |  |

Definition at line 946 of file win32ole.c.

## ◆ oledata_get_struct()

struct oledata* oledata_get_struct | ( | VALUE | ole | ) |

Definition at line 857 of file win32ole.c.

References TypedData_Get_Struct.

Referenced by ole_val2variant(), and typelib_from_val().

## ◆ reg_enum_key()

VALUE reg_enum_key | ( | HKEY | hkey,
|  | DWORD | i
| ) |  |

Definition at line 1710 of file win32ole.c.

References buf, BUFSIZ, err, i, NULL, Qnil, and rb_str_new2.

## ◆ reg_get_val()

VALUE reg_get_val | ( | HKEY | hkey,
|  | const char * | subkey
| ) |  |

Definition at line 1725 of file win32ole.c.

References ALLOC_N, err, free(), len, NULL, Qnil, rb_str_new2, and size.

Referenced by reg_get_val2().

## ◆ reg_get_val2()

VALUE reg_get_val2 | ( | HKEY | hkey,
|  | const char * | subkey
| ) |  |

Definition at line 1753 of file win32ole.c.

References err, NULL, Qnil, and reg_get_val().

## ◆ reg_open_key()

LONG reg_open_key | ( | HKEY | hkey,
|  | const char * | name,
|  | HKEY * | phkey
| ) |  |

Definition at line 1698 of file win32ole.c.

References name.

Referenced by reg_open_vkey().

## ◆ reg_open_vkey()

LONG reg_open_vkey | ( | HKEY | hkey,
|  | VALUE | key,
|  | HKEY * | phkey
| ) |  |

Definition at line 1704 of file win32ole.c.

References key, reg_open_key(), and StringValuePtr.

## ◆ typelib_from_val()

HRESULT typelib_from_val | ( | VALUE | obj,
|  | ITypeLib ** | pTypeLib
| ) |  |

Definition at line 3908 of file win32ole.c.

References cWIN32OLE_lcid, HRESULT(), index, lcid, NULL, obj, OLE_RELEASE, oledata_get_struct(), and oledata::pDispatch.

## ◆ val2variant_ptr()

VOID* val2variant_ptr | ( | VALUE | val,
|  | VARIANT * | var,
|  | VARTYPE | vt
| ) |  |

Definition at line 1017 of file win32ole.c.

References cWIN32OLE_lcid, HRESULT(), NULL, ole_raise(), ole_val2variant_ex(), and rb_eRuntimeError.

## Variable Documentation

## ◆ cNames

static REFIID LPOLESTR __RPC_FAR UINT cNames

Definition at line 88 of file win32ole.c.

Referenced by EVENTSINK_GetIDsOfNames().

## ◆ cWIN32OLE

VALUE cWIN32OLE

Definition at line 38 of file win32ole.c.

Referenced by Init_win32ole_variant_m(), and ole_val2variant().

## ◆ dispIdMember

DISPID dispIdMember

Definition at line 89 of file win32ole.c.

## ◆ dwCallType

DWORD dwCallType

Definition at line 216 of file win32ole.c.

## ◆ dwPendingType

HTASK DWORD DWORD dwPendingType

Initial value:
{
if (rb_during_gc()) {
return PENDINGMSG_WAITNOPROCESS;
}
if (previous_filter) {
return previous_filter->lpVtbl->MessagePending(previous_filter,
threadIDCallee,
dwTickCount,
dwPendingType);
}
return PENDINGMSG_WAITNOPROCESS

Definition at line 270 of file win32ole.c.

## ◆ dwRejectType

HTASK DWORD DWORD dwRejectType

Initial value:
{
if (previous_filter) {
return previous_filter->lpVtbl->RetryRejectedCall(previous_filter,
threadIDCallee,
dwTickCount,
dwRejectType);
}
return 1000

Definition at line 254 of file win32ole.c.

## ◆ dwTickCount

static HTASK DWORD dwTickCount

Definition at line 218 of file win32ole.c.

## ◆ iTInfo

static UINT iTInfo

Definition at line 87 of file win32ole.c.

## ◆ lcid

static REFIID LPOLESTR __RPC_FAR UINT LCID lcid

Definition at line 87 of file win32ole.c.

Referenced by typelib_from_val().

## ◆ lpInterfaceInfo

DWORD HTASK DWORD LPINTERFACEINFO lpInterfaceInfo

Initial value:
{
switch (dwCallType)
{
case CALLTYPE_ASYNC:
case CALLTYPE_TOPLEVEL_CALLPENDING:
case CALLTYPE_ASYNC_CALLPENDING:
if (rb_during_gc()) {
return SERVERCALL_RETRYLATER;
}
break;
default:
break;
}
if (previous_filter) {
return previous_filter->lpVtbl->HandleInComingCall(previous_filter,
dwCallType,
threadIDCaller,
dwTickCount,
lpInterfaceInfo);
}
return SERVERCALL_ISHANDLED

Definition at line 221 of file win32ole.c.

## ◆ nameid

ID nameid = rb_check_id_cstr(psz, (long)strlen(psz), cWIN32OLE_enc)

Definition at line 355 of file win32ole.c.

## ◆ pctinfo

static UINT __RPC_FAR * pctinfo

Initial value:
{
return E_NOTIMPL

Definition at line 86 of file win32ole.c.

## ◆ pDispParams

DISPID REFIID LCID WORD DISPPARAMS __RPC_FAR* pDispParams

Definition at line 89 of file win32ole.c.

## ◆ pExcepInfo

DISPID REFIID LCID WORD DISPPARAMS __RPC_FAR VARIANT __RPC_FAR EXCEPINFO __RPC_FAR* pExcepInfo

Definition at line 89 of file win32ole.c.

## ◆ ppTInfo

static UINT LCID ITypeInfo __RPC_FAR *__RPC_FAR * ppTInfo

Initial value:
{
return E_NOTIMPL

Definition at line 87 of file win32ole.c.

## ◆ ppvObject

static REFIID void __RPC_FAR *__RPC_FAR * ppvObject

Initial value:
{
if (MEMCMP(riid, &IID_IUnknown, GUID, 1) == 0
|| MEMCMP(riid, &IID_IMessageFilter, GUID, 1) == 0)
{
*ppvObject = &message_filter;
return S_OK;
}
return E_NOINTERFACE

Definition at line 83 of file win32ole.c.

## ◆ puArgErr

DISPID REFIID LCID WORD DISPPARAMS __RPC_FAR VARIANT __RPC_FAR EXCEPINFO __RPC_FAR UINT __RPC_FAR* puArgErr

Definition at line 89 of file win32ole.c.

## ◆ pVarResult

DISPID REFIID LCID WORD DISPPARAMS __RPC_FAR VARIANT __RPC_FAR* pVarResult

Definition at line 89 of file win32ole.c.

## ◆ rgDispId

static REFIID LPOLESTR __RPC_FAR UINT LCID DISPID __RPC_FAR * rgDispId

Initial value:
{
char* psz = ole_wc2mb(*rgszNames)

Definition at line 88 of file win32ole.c.

## ◆ rgszNames

static REFIID LPOLESTR __RPC_FAR * rgszNames

Definition at line 88 of file win32ole.c.

## ◆ riid

static REFIID riid

Definition at line 83 of file win32ole.c.

## ◆ threadIDCallee

static HTASK threadIDCallee

Definition at line 250 of file win32ole.c.

## ◆ threadIDCaller

DWORD HTASK threadIDCaller

Definition at line 217 of file win32ole.c.

## ◆ wFlags

DISPID REFIID LCID WORD wFlags

Definition at line 89 of file win32ole.c.

dwRejectType
static HTASK DWORD DWORD dwRejectType
Definition: win32ole.c:254
ppvObject
static REFIID void __RPC_FAR *__RPC_FAR * ppvObject
Definition: win32ole.c:83
rb_during_gc
int rb_during_gc(void)
Definition: gc.c:8687
dwTickCount
static DWORD HTASK DWORD dwTickCount
Definition: win32ole.c:218
threadIDCaller
static DWORD HTASK threadIDCaller
Definition: win32ole.c:217
riid
static REFIID riid
Definition: win32ole.c:83
dwCallType
static DWORD dwCallType
Definition: win32ole.c:216
MEMCMP
#define MEMCMP(p1, p2, type, n)
Definition: ruby.h:1755
dwPendingType
static HTASK DWORD DWORD dwPendingType
Definition: win32ole.c:270
rgszNames
static REFIID LPOLESTR __RPC_FAR * rgszNames
Definition: win32ole.c:88
threadIDCallee
static HTASK threadIDCallee
Definition: win32ole.c:250
ole_wc2mb
char * ole_wc2mb(LPWSTR pw)
Definition: win32ole.c:743
lpInterfaceInfo
static DWORD HTASK DWORD LPINTERFACEINFO lpInterfaceInfo
Definition: win32ole.c:221