Reflection API to access COM objects sample

quoted from URL

Object o;
System.Type t = Type.GetTypeFromProgID("MODI.Document");
o = System.Activator.CreateInstance(t);

Object[] a = new Object[1];
a[0] = "C:\\Temp\\iri36300.TIF";

t.InvokeMember("Create", BindingFlags.InvokeMethod, null, o, a);
Object images = t.InvokeMember( "Images", BindingFlags.GetProperty, null, o, new Object[] {} );
Type imagesType = images.GetType();
Object item = imagesType.InvokeMember( "Item", BindingFlags.GetProperty, null, images, new Object[] {"0"} );
Type itemType = item.GetType();
itemType.InvokeMember("OCR", BindingFlags.InvokeMethod, null, item, new Object[] { 9 } );
Object layout = itemType.InvokeMember("Layout", BindingFlags.GetProperty, null, item, new Object[] {} );
Type layoutType = layout.GetType();
Object ocrResult = layoutType.InvokeMember( "Text", BindingFlags.GetProperty, null, layout, new Object[] {} );

Comments

Popular posts from this blog

Outlook : "operation failed, object could not be found. " when trying to close a PST.

How to transfer app and data from old iPhone to new iPhone for model IOS17 and IOS18 above.

Troubleshooting Outlook Express (IMAP, POP3, HTTP, NEWS) with the log file