private static int GetIDsOfNames(IDispatch dispatch, string name, out int dispId) { int[] dispIds = new int[1]; Guid emtpyRiid = Guid.Empty; int hresult = dispatch.TryGetIDsOfNames( ref emtpyRiid, new string[] { name }, 1, 0, dispIds); dispId = dispIds[0]; return(hresult); }
public static IntPtr GetIdsOfNamedParameters(IDispatch dispatch, string[] names, int methodDispId, out GCHandle pinningHandle) { pinningHandle = GCHandle.Alloc(null, GCHandleType.Pinned); int[] dispIds = new int[names.Length]; Guid empty = Guid.Empty; int hresult = dispatch.TryGetIDsOfNames(ref empty, names, (uint)names.Length, 0, dispIds); if (hresult < 0) { Marshal.ThrowExceptionForHR(hresult); } if (methodDispId != dispIds[0]) { throw Error.GetIDsOfNamesInvalid(names[0]); } int[] keywordArgDispIds = dispIds.RemoveFirst(); // Remove the dispId of the method name pinningHandle.Target = keywordArgDispIds; return Marshal.UnsafeAddrOfPinnedArrayElement(keywordArgDispIds, 0); }
private static int GetIDsOfNames(IDispatch dispatch, string name, out int dispId) { int[] dispIds = new int[1]; Guid emtpyRiid = Guid.Empty; int hresult = dispatch.TryGetIDsOfNames( ref emtpyRiid, new string[] { name }, 1, 0, dispIds); dispId = dispIds[0]; return hresult; }