Skip to content

Commit dbf5a61

Browse files
committed
Get coclass name from IControl instead of interface name.
1 parent cd591ab commit dbf5a61

File tree

1 file changed

+3
-51
lines changed
  • Rubberduck.VBEEditor/SafeComWrappers/Office.Core/Abstract

1 file changed

+3
-51
lines changed
Lines changed: 3 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using System;
2-
using System.Runtime.InteropServices;
3-
using System.Runtime.InteropServices.ComTypes;
2+
using System.ComponentModel;
43
using Rubberduck.VBEditor.SafeComWrappers.Abstract;
54

65
namespace Rubberduck.VBEditor.SafeComWrappers.Office.Core.Abstract
@@ -16,59 +15,12 @@ public static string TypeName(this IControl control)
1615
{
1716
try
1817
{
19-
var dispatch = control.Target as IDispatch;
20-
if (dispatch == null)
21-
{
22-
return "Control";
23-
}
24-
ITypeInfo info;
25-
dispatch.GetTypeInfo(0, 0, out info);
26-
string name;
27-
string docs;
28-
int context;
29-
string help;
30-
info.GetDocumentation(-1, out name, out docs, out context, out help);
31-
return name;
18+
return TypeDescriptor.GetClassName(control.Target);
3219
}
3320
catch
3421
{
3522
return "Control";
3623
}
37-
}
38-
39-
[ComImport]
40-
[Guid("00020400-0000-0000-C000-000000000046")]
41-
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
42-
interface IDispatch
43-
{
44-
[PreserveSig]
45-
int GetTypeInfoCount(out int Count);
46-
47-
[PreserveSig]
48-
int GetTypeInfo(
49-
[MarshalAs(UnmanagedType.U4)] int iTInfo,
50-
[MarshalAs(UnmanagedType.U4)] int lcid,
51-
out ITypeInfo typeInfo);
52-
53-
[PreserveSig]
54-
int GetIDsOfNames(
55-
ref Guid riid,
56-
[MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.LPWStr)]
57-
string[] rgsNames,
58-
int cNames,
59-
int lcid,
60-
[MarshalAs(UnmanagedType.LPArray)] int[] rgDispId);
61-
62-
[PreserveSig]
63-
int Invoke(
64-
int dispIdMember,
65-
ref Guid riid,
66-
uint lcid,
67-
ushort wFlags,
68-
ref System.Runtime.InteropServices.ComTypes.DISPPARAMS pDispParams,
69-
out object pVarResult,
70-
ref System.Runtime.InteropServices.ComTypes.EXCEPINFO pExcepInfo,
71-
IntPtr[] pArgErr);
72-
}
24+
}
7325
}
7426
}

0 commit comments

Comments
 (0)