How can I find out about undocumented .NET / COM library functions?

How do I know the properties and methods of COM objects returned from some .NET functions that appear to be undocumented?

In the specific example I'm looking at, I paste the image into Excel using the following function:

Set NewPic = ActiveSheet.Pictures.Insert(FileName) 

(See the SO post here here .)

However, the MSDN documentation for this function only says that Worksheet.Pictures returns an object, and when I put the clock on a variable during debugging, its type is System .__ ComObject. Can I find out what other properties and functions may be available for this class (for example, I want to change the alternative text for the image)? How would a person who learned about the Insert function even know about it?

The MSDN document also talks about such features that they are "not intended to be used directly from your code," but let it be ignored for now ...

Thanks!


Edit: Well, I was able to at least answer my specific question. Instead of using Worksheet.Pictures.Insert you can use Worksheet.Shapes.AddPicture to return the correct (documented) Excel.Shape class:

 pic = range.Worksheet.Shapes.AddPicture(tmpFile, Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoTriState.msoCTrue, range.Left, range.Top, image.Width, image.Height) pic.AlternativeText = "Help!" 

They will continue to be interested in any resources for undocumented functions.

+2
source share
1 answer

One way to find this is to use the OleView tool (which you can download from Microsoft here ). This tool allows you to browse COM-type libraries. A type library (provided that the provider of the provided COM information provided information about the type library) contains information about the interfaces and methods and properties of the COM classes that are opened by the application or library.

For example, on my machine, I can view the type library for C:\Program Files\Microsoft Office\Office12\EXCEL.EXE and see what COM objects Excel opens, as well as their properties and methods. OleView displays information in IDL (Interface Description Language), which is more or less a prototype of the C function with added attributes).

This is the IDL declaration I received with OleView for the __Worksheet.Pictures property:

  [id(0x00000303), hidden, helpcontext(0x00010303)] HRESULT Pictures( [in, optional] VARIANT Index, [in, lcid] long lcid, [out, retval] IDispatch** RHS); 

Notice the hidden attribute in the declaration. This means that most IDEs will not be displayed (and this is a good hint to not rely on this method, which always exists). Microsoft may remove it in a later version of Excel).

What about the Pictures class? Here is the full IDL:

 [ uuid(000208A7-0000-0000-C000-000000000046), helpcontext(0x00020067), hidden ] dispinterface Pictures { properties: methods: [id(0x60000000), restricted] void QueryInterface( [in] GUID* riid, [out] void** ppvObj); [id(0x60000001), restricted] unsigned long AddRef(); [id(0x60000002), restricted] unsigned long Release(); [id(0x60010000), restricted] void GetTypeInfoCount([out] unsigned int* pctinfo); [id(0x60010001), restricted] void GetTypeInfo( [in] unsigned int itinfo, [in] unsigned long lcid, [out] void** pptinfo); [id(0x60010002), restricted] void GetIDsOfNames( [in] GUID* riid, [in] char** rgszNames, [in] unsigned int cNames, [in] unsigned long lcid, [out] long* rgdispid); [id(0x60010003), restricted] void Invoke( [in] long dispidMember, [in] GUID* riid, [in] unsigned long lcid, [in] unsigned short wFlags, [in] DISPPARAMS* pdispparams, [out] VARIANT* pvarResult, [out] EXCEPINFO* pexcepinfo, [out] unsigned int* puArgErr); [id(0x00000094), propget, helpcontext(0x00010094)] Application* Application(); [id(0x00000095), propget, helpcontext(0x00010095)] XlCreator Creator(); [id(0x00000096), propget, helpcontext(0x00010096)] IDispatch* Parent(); [id(0x00010003), restricted, hidden] void _Dummy3(); [id(0x0000025a), helpcontext(0x0001025a)] VARIANT BringToFront(); [id(0x00000227), helpcontext(0x00010227)] VARIANT Copy(); [id(0x000000d5), helpcontext(0x000100d5)] VARIANT CopyPicture( [in, optional, defaultvalue(2)] XlPictureAppearance Appearance, [in, optional, defaultvalue(-4147)] XlCopyPictureFormat Format); [id(0x00000235), helpcontext(0x00010235)] VARIANT Cut(); [id(0x00000075), helpcontext(0x00010075)] VARIANT Delete(); [id(0x0000040f), helpcontext(0x0001040f)] IDispatch* Duplicate(); [id(0x00000258), propget, helpcontext(0x00010258)] VARIANT_BOOL Enabled(); [id(0x00000258), propput, helpcontext(0x00010258)] void Enabled([in] VARIANT_BOOL rhs); [id(0x0000007b), propget, helpcontext(0x0001007b)] double Height(); [id(0x0000007b), propput, helpcontext(0x0001007b)] void Height([in] double rhs); [id(0x0001000c), restricted, hidden] void _Dummy12(); [id(0x0000007f), propget, helpcontext(0x0001007f)] double Left(); [id(0x0000007f), propput, helpcontext(0x0001007f)] void Left([in] double rhs); [id(0x0000010d), propget, helpcontext(0x0001010d)] VARIANT_BOOL Locked(); [id(0x0000010d), propput, helpcontext(0x0001010d)] void Locked([in] VARIANT_BOOL rhs); [id(0x0001000f), restricted, hidden] void _Dummy15(); [id(0x00000254), propget, hidden, helpcontext(0x00010254)] BSTR OnAction(); [id(0x00000254), propput, hidden, helpcontext(0x00010254)] void OnAction([in] BSTR rhs); [id(0x00000269), propget, helpcontext(0x00010269)] VARIANT Placement(); [id(0x00000269), propput, helpcontext(0x00010269)] void Placement([in] VARIANT rhs); [id(0x0000026a), propget, helpcontext(0x0001026a)] VARIANT_BOOL PrintObject(); [id(0x0000026a), propput, helpcontext(0x0001026a)] void PrintObject([in] VARIANT_BOOL rhs); [id(0x000000eb), helpcontext(0x000100eb)] VARIANT Select([in, optional] VARIANT Replace); [id(0x0000025d), helpcontext(0x0001025d)] VARIANT SendToBack(); [id(0x0000007e), propget, helpcontext(0x0001007e)] double Top(); [id(0x0000007e), propput, helpcontext(0x0001007e)] void Top([in] double rhs); [id(0x00010016), restricted, hidden] void _Dummy22(); [id(0x0000022e), propget, helpcontext(0x0001022e)] VARIANT_BOOL Visible(); [id(0x0000022e), propput, helpcontext(0x0001022e)] void Visible([in] VARIANT_BOOL rhs); [id(0x0000007a), propget, helpcontext(0x0001007a)] double Width(); [id(0x0000007a), propput, helpcontext(0x0001007a)] void Width([in] double rhs); [id(0x0000026e), propget, helpcontext(0x0001026e)] long ZOrder(); [id(0x000005f8), propget, helpcontext(0x000105f8)] ShapeRange* ShapeRange(); [id(0x00000080), propget, helpcontext(0x00010080)] Border* Border(); [id(0x00000081), propget, helpcontext(0x00010081)] Interior* Interior(); [id(0x00000067), propget, helpcontext(0x00010067)] VARIANT_BOOL Shadow(); [id(0x00000067), propput, helpcontext(0x00010067)] void Shadow([in] VARIANT_BOOL rhs); [id(0x00000105), propget, helpcontext(0x00010105)] BSTR Formula(); [id(0x00000105), propput, helpcontext(0x00010105)] void Formula([in] BSTR rhs); [id(0x000000b5), helpcontext(0x000100b5)] Picture* Add( [in] double Left, [in] double Top, [in] double Width, [in] double Height); [id(0x00000076), propget, helpcontext(0x00010076)] long Count(); [id(0x0000002e), helpcontext(0x0001002e)] GroupObject* Group(); [id(0x000000fc), helpcontext(0x000100fc)] Picture* Insert( [in] BSTR Filename, [in, optional] VARIANT Converter); [id(0x000000aa), helpcontext(0x000100aa)] IDispatch* Item([in] VARIANT Index); [id(0xfffffffc), helpcontext(0x0000fffc)] IUnknown* _NewEnum(); [id(0x000000d3), helpcontext(0x000100d3)] Picture* Paste([in, optional] VARIANT Link); 

From this, you can assume that the Pictures interface has the Cut and Delete methods, as well as the Item property, among others. However, note that this interface is also marked hidden , which (again) is a good indicator that you should not use it (yes, I know that you ignored this warning, but I'm the second Mitch Pete, I comment that he generally It’s a bad idea to use hidden classes because they are usually intended for internal use by the application and are subject to change without notice.)

+7
source

Source: https://habr.com/ru/post/897297/


All Articles