public int TryInvokePropertyGet(string propertyName, out object value) { int hr = NativeMethods.S_OK; IDispatch dispatch = null; value = null; try { if (IsDispatch) { dispatch = TryGetUniqueRCW <IDispatch>(); if (dispatch != null) { if (MarshalEx.Succeeded(hr = dispatch.InvokePropertyGet(propertyName, out value))) { } } } } catch { } finally { ComPtr.CleanupUniqueRCW(dispatch); } return(hr); }
public static int InvokePropertyGet(this IDispatch dispatch, string name, out object value) { int hr = NativeMethods.S_OK; value = null; int dispid = 0; if (MarshalEx.Succeeded(dispatch.GetIdOfName(name, out dispid))) { hr = dispatch.InvokePropertyGet(dispid, out value); } return(hr); }
public int TryGetItemCount() { IDispatch dispatch = null; object count = 0; try { dispatch = TryGetUniqueRCW <IDispatch>(); if (MarshalEx.Succeeded(dispatch.InvokePropertyGet("Count", out count))) { return(count is int?(int)count : -1); } } catch { } finally { CleanupUniqueRCW(dispatch); } return(-1); }