@@ -14,92 +14,4 @@ static void Main(string[] args)
14
14
Console . WriteLine ( t . Name ) ;
15
15
}
16
16
}
17
- }
18
-
19
- /*namespace System.Runtime.InteropServices.ComTypes
20
- {
21
- using System.Collections;
22
-
23
- [Guid("496B0ABE-CDEE-11d3-88E8-00902754C43A")]
24
- internal interface IEnumerable
25
- {
26
- [DispId(-4)]
27
- IEnumerator GetEnumerator();
28
- }
29
-
30
- [ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("00020400-0000-0000-C000-000000000046")]
31
- internal interface IDispatch
32
- {
33
- [PreserveSig]
34
- int GetTypeInfoCount(out int info);
35
-
36
- [PreserveSig]
37
- int GetTypeInfo(int iTInfo, int lcid, out ComTypes.ITypeInfo ppTInfo);
38
-
39
- void GetIDsOfNames([MarshalAs(UnmanagedType.LPStruct)] Guid iid, [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.LPWStr)] string[] rgszNames, int cNames, int lcid, [Out, MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.I4)] int[] rgDispId);
40
-
41
- void Invoke(int dispIdMember, [MarshalAs(UnmanagedType.LPStruct)] Guid iid, int lcid, ComTypes.INVOKEKIND wFlags, [In, Out] [MarshalAs(UnmanagedType.LPArray)] ComTypes.DISPPARAMS[] paramArray, out object pVarResult, out ComTypes.EXCEPINFO pExcepInfo, out uint puArgErr);
42
- }
43
-
44
- internal static class COMHelper
45
- {
46
- public static int GetDispId(object rcw, string methodName)
47
- {
48
- IDispatch dispatchObject = rcw as IDispatch;
49
- if (dispatchObject == null)
50
- {
51
- Console.WriteLine("Passed-in argument is not a IDispatch object");
52
- return -1;
53
- }
54
-
55
-
56
- int[] dispIds = new int[1];
57
- Guid emtpyRiid = Guid.Empty;
58
- dispatchObject.GetIDsOfNames(
59
- emtpyRiid,
60
- new string[] { methodName },
61
- 1,
62
- 0,
63
- dispIds);
64
-
65
- if (dispIds[0] == -1)
66
- {
67
- Console.WriteLine("Method name {0} cannot be recognized.", methodName);
68
- }
69
-
70
- return dispIds[0];
71
- }
72
-
73
- public static object Invoke(IDispatch target, int dispId)
74
- {
75
- if (target == null) { Console.WriteLine("Cannot cast target to IDispatch."); return null; }
76
-
77
- IntPtr variantArgArray = IntPtr.Zero, dispIdArray = IntPtr.Zero, tmpVariants = IntPtr.Zero;
78
- int argCount = 0;
79
-
80
- var paramArray = new ComTypes.DISPPARAMS[1];
81
- paramArray[0].rgvarg = variantArgArray;
82
- paramArray[0].cArgs = argCount;
83
- paramArray[0].cNamedArgs = 0;
84
- paramArray[0].rgdispidNamedArgs = IntPtr.Zero;
85
-
86
- ComTypes.EXCEPINFO info = default(ComTypes.EXCEPINFO);
87
- object result = null;
88
-
89
- try
90
- {
91
- uint puArgErrNotUsed = 0;
92
- target.Invoke(dispId, new Guid(), 0x0409, ComTypes.INVOKEKIND.INVOKE_FUNC, paramArray, out result, out info, out puArgErrNotUsed);
93
- }
94
- catch (Exception ex)
95
- {
96
- Console.WriteLine("IDispatch.Invoke failed: {0}", ex.Message);
97
- }
98
-
99
- return result;
100
- }
101
-
102
- [DllImport("ole32.dll")]
103
- internal static extern int CLSIDFromProgID([MarshalAs(UnmanagedType.LPWStr)] string lpszProgID, out Guid pclsid);
104
- }
105
- }*/
17
+ }
0 commit comments