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[] {} );


Popular posts from this blog

Clearcase check in/uncheck out all the checked out files script

Duplicating a local copy of project from TFS and making web software client factory to work