Any way to avoid creating a huge C# COM interface wrapper when only a few methods needed? -


All greetings,

I am working on a C # program for which to get the index To be able to do this through the UI automation, by checking the custom properties of the control, fortunately, the hot item in the new item view control of Windows 7 Explorer must be enabled.

Unfortunately, the system. One way to find custom properties in the Windows. Automation Namespace can not be provided! It completely dumps the C # Automation Namespace and leaves it with the undesirable situation of using only the unmanaged COM version. One way to do this is to put all the automation code into a separate C ++ / CLI module and call it through my C # application. However, if possible, I would like to avoid this option because it adds more files to my project, and I have to worry about 32/64-bit problems and so on.

The second option is to use the ComImport attribute to declare the relevant interface and do everything via COM-interop. This is what I want to do, however, the relevant interface, such as IUUutomation and IUIutomationElement, There are huge throwing. In his total hundreds of methods, and tons of reference tones and interfaces (which I think I must declare too), almost all of which I will never use. I do not think the UI automation interface has been announced in any type of library, so I can not use TLBIMP.

Can I avoid translating bajillion method signatures manually in C #, instead of just declaring ten or so methods which I really need? I think C # 4.0 has added a new "dynamic" type which should reduce the COM interop; Is that related to my problem?

Thanks

Most importantly (from C # to call the COM method From Perspective) It is that the methods appear in the correct order in the interface. If you are not using any method, you can declare it as zero and nothing will be bad (unless you actually call!). This prevents you from preparing the correct signature and defining all other types, etc. For example, [CommIimport, Gid ("30cbe57d-d9d0-452a-ab13-7ac5ac4825ee"), Interface type (Commander interface type.Interface ISI unknown) Interface IUIAutomation {Compare with zero elements ( ); Compare zero to tranmide (); Zero GetRootElement (); // 50 or other ways ... // ... only define the signature for those you really need)

Methods should be defined in the same order , Which they appear in UIAutomationClient.h (in Windows SDK).


Comments