当前位置: 首页>>代码示例>>Java>>正文


Java IJIDispatch.callMethod方法代码示例

本文整理汇总了Java中org.jinterop.dcom.impls.automation.IJIDispatch.callMethod方法的典型用法代码示例。如果您正苦于以下问题:Java IJIDispatch.callMethod方法的具体用法?Java IJIDispatch.callMethod怎么用?Java IJIDispatch.callMethod使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.jinterop.dcom.impls.automation.IJIDispatch的用法示例。


在下文中一共展示了IJIDispatch.callMethod方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: closePresentation

import org.jinterop.dcom.impls.automation.IJIDispatch; //导入方法依赖的package包/类
public void closePresentation(IJIDispatch presentation) throws JIException
{
	presentation.callMethod("Close");
}
 
开发者ID:howie,项目名称:jinterop,代码行数:5,代码来源:MSPowerPoint2.java

示例2: savePresentationAs

import org.jinterop.dcom.impls.automation.IJIDispatch; //导入方法依赖的package包/类
public void savePresentationAs(IJIDispatch presentation, String fullEscapedPath) throws JIException
{
	presentation.callMethod("SaveAs", new Object[]{new JIString(fullEscapedPath).Variant,JIVariant.OPTIONAL_PARAM(),new Integer(-1)});
}
 
开发者ID:howie,项目名称:jinterop,代码行数:5,代码来源:MSPowerPoint2.java

示例3: goto_First_Slide

import org.jinterop.dcom.impls.automation.IJIDispatch; //导入方法依赖的package包/类
public void goto_First_Slide(IJIDispatch view) throws JIException
{
	view.callMethod("First");
}
 
开发者ID:howie,项目名称:jinterop,代码行数:5,代码来源:MSPowerPoint2.java

示例4: goto_Last_Slide

import org.jinterop.dcom.impls.automation.IJIDispatch; //导入方法依赖的package包/类
public void goto_Last_Slide(IJIDispatch view) throws JIException
{
	view.callMethod("Last");
}
 
开发者ID:howie,项目名称:jinterop,代码行数:5,代码来源:MSPowerPoint2.java

示例5: do_Next_Action

import org.jinterop.dcom.impls.automation.IJIDispatch; //导入方法依赖的package包/类
public void do_Next_Action(IJIDispatch view) throws JIException
{
	view.callMethod("Next");
}
 
开发者ID:howie,项目名称:jinterop,代码行数:5,代码来源:MSPowerPoint2.java

示例6: do_Previous_Action

import org.jinterop.dcom.impls.automation.IJIDispatch; //导入方法依赖的package包/类
public void do_Previous_Action(IJIDispatch view) throws JIException
{
	view.callMethod("Previous");
}
 
开发者ID:howie,项目名称:jinterop,代码行数:5,代码来源:MSPowerPoint2.java

示例7: goto_Numbered_Slide

import org.jinterop.dcom.impls.automation.IJIDispatch; //导入方法依赖的package包/类
public void goto_Numbered_Slide(IJIDispatch view, int index) throws JIException
{
	view.callMethod("GotoSlide", new Object[]{new Integer(index), JIVariant.OPTIONAL_PARAM()});
}
 
开发者ID:howie,项目名称:jinterop,代码行数:5,代码来源:MSPowerPoint2.java

示例8: main

import org.jinterop.dcom.impls.automation.IJIDispatch; //导入方法依赖的package包/类
/**
 * @param args
 */
public static void main(String[] args) {
	
	if (args.length < 4)
    {
    	System.out.println("Please provide address domain username password");
    	return;
    }
	
	
	
	try {
		
		JISystem.setAutoRegisteration(true);
		JISystem.setInBuiltLogHandler(false);
		JISystem.getLogger().setLevel(Level.ALL);
		JISession session1 = JISession.createSession(args[1],args[2],args[3]);
		JISession session2 = JISession.createSession(args[1],args[2],args[3]);
		JIComServer testServer1 = new JIComServer(JIProgId.valueOf("TestJavaServer.TestServer1"),args[0],session1);
		IJIComObject unkTestServer1 = testServer1.createInstance();
		IJIComObject testServer1Intf = JIObjectFactory.narrowObject(unkTestServer1.queryInterface("2A93A24D-59FE-4DE0-B67E-B8D41C9F57F8"));
		IJIDispatch dispatch1 = (IJIDispatch)JIObjectFactory.narrowObject(unkTestServer1.queryInterface(IJIDispatch.IID));;
		
		//First lets call the ITestServer1.Call_TestServer2_Java using the Dispatch interface
		//Acquire a reference to ITestServer2
		JIComServer testServer2 = new JIComServer(JIProgId.valueOf("TestJavaServer.TestServer2"),args[0],session2);
		IJIComObject unkTestServer2 = testServer2.createInstance();
		//Get the interface pointer to ITestServer2
		IJIComObject iTestServer2 = (IJIComObject)JIObjectFactory.narrowObject(unkTestServer2.queryInterface("9CCC5120-457D-49F3-8113-90F7E97B54A7"));
	
		IJIDispatch dispatch2 = (IJIDispatch)JIObjectFactory.narrowObject(unkTestServer2.queryInterface(IJIDispatch.IID));;
		
		//send it directly without IDispatch interface, please note that the "dispatchNotSupported" flag of JICallBuilder is "false".
		JICallBuilder callObject = new JICallBuilder(false);
		callObject.addInParamAsComObject(iTestServer2, JIFlags.FLAG_NULL);
		callObject.setOpnum(0);
		testServer1Intf.call(callObject);
		
		//Send it to ITestServer.Call_TestServer2_Java2 via IDispatch of ITestServer1. Notice that pointer here id IDispatch.
		dispatch1.callMethod("Call_TestServer2_Java2", new Object[]{new JIVariant(dispatch2)});
		
		//Send it to ITestServer.Call_TestServer2_Java via IDispatch of ITestServer1.
		dispatch1.callMethod("Call_TestServer2_Java", new Object[]{new JIVariant(iTestServer2)});
		
		
		//Now for the Java Implementation of ITestServer2 interface (from the type library or IDL)  
		//IID of ITestServer2 interface
		JILocalInterfaceDefinition interfaceDefinition = new JILocalInterfaceDefinition("9CCC5120-457D-49F3-8113-90F7E97B54A7");
		//lets define the method "Execute" now. Please note that either this should be in the same order as defined in IDL
		//or use the addInParamAsObject with opnum parameter function.
		JILocalParamsDescriptor parameterObject = new JILocalParamsDescriptor();
		parameterObject.addInParamAsObject(new JIString(JIFlags.FLAG_REPRESENTATION_STRING_BSTR),JIFlags.FLAG_REPRESENTATION_STRING_BSTR);
		JILocalMethodDescriptor methodDescriptor = new JILocalMethodDescriptor("Execute",1,parameterObject);
		interfaceDefinition.addMethodDescriptor(methodDescriptor);
		//Create the Java Server class. This contains the instance to be called by the COM Server ITestServer1.
		JILocalCoClass _testServer2 = new JILocalCoClass(interfaceDefinition,new Test_ITestServer2_Impl());
		//Get a interface pointer to the Java CO Class. The template could be any IJIComObject since only the session is reused.
		IJIComObject __testServer2 = JIObjectFactory.buildObject(session1,_testServer2); 
		//Call our Java server. The same message should be printed on the Java console.
		dispatch1.callMethod("Call_TestServer2_Java", new Object[]{new JIVariant(__testServer2)});
		
	} catch (Exception e) {
		e.printStackTrace();
	} 
	

}
 
开发者ID:howie,项目名称:jinterop,代码行数:70,代码来源:Test_ITestServer2_Impl.java

示例9: performOp

import org.jinterop.dcom.impls.automation.IJIDispatch; //导入方法依赖的package包/类
public void performOp() throws JIException, InterruptedException
{
	//JIVariant variant = dispatch.get("Presentations");
	//JIInterfacePointer ptr = variant.getObjectAsInterfacePointer();
	//IJIDispatch presentations = (IJIDispatch)JIObjectFactory.createCOMInstance(unknown,ptr);
	IJIDispatch presentations = (IJIDispatch)JIObjectFactory.narrowObject(dispatch.get("Presentations").getObjectAsComObject());

	for (int i = 0; i < 2; i++)
	{
		JIVariant results[] = presentations.callMethodA("Add",new Object[]{JIVariant.OPTIONAL_PARAM()});
		//variant = results[0];
		//ptr = variant.getObjectAsInterfacePointer();
		//IJIDispatch presentation = (IJIDispatch)JIObjectFactory.createCOMInstance(unknown,ptr);
		IJIDispatch presentation = (IJIDispatch)JIObjectFactory.narrowObject(results[0].getObjectAsComObject());
		//variant = presentation.get("Slides");
		//ptr = variant.getObjectAsInterfacePointer();
		//IJIDispatch slides = (IJIDispatch)JIObjectFactory.createCOMInstance(unknown,ptr);
		IJIDispatch slides = (IJIDispatch)JIObjectFactory.narrowObject(presentation.get("Slides").getObjectAsComObject());

		results = slides.callMethodA("Add", new Object[]{new Integer(1),new Integer(1)});
		//variant = results[0];
		//ptr = variant.getObjectAsInterfacePointer();
		IJIDispatch slide = (IJIDispatch)JIObjectFactory.narrowObject(results[0].getObjectAsComObject());

		//variant = slide.get("Shapes");
		//ptr = variant.getObjectAsInterfacePointer();
		IJIDispatch shapes = (IJIDispatch)JIObjectFactory.narrowObject(slide.get("Shapes").getObjectAsComObject());

		//variant = shapes.get("Title");
		//ptr = variant.getObjectAsInterfacePointer();
		IJIDispatch shape = (IJIDispatch)JIObjectFactory.narrowObject(shapes.get("Title").getObjectAsComObject());

		//variant = shape.get("TextFrame");
		//ptr = variant.getObjectAsInterfacePointer();
		IJIDispatch textframe = (IJIDispatch)JIObjectFactory.narrowObject(shape.get("TextFrame").getObjectAsComObject());

		//variant = textframe.get("TextRange");
		//ptr = variant.getObjectAsInterfacePointer();
		IJIDispatch textrange = (IJIDispatch)JIObjectFactory.narrowObject(textframe.get("TextRange").getObjectAsComObject());

		if (i == 0)
		{
			textrange.put("Text",new JIString("Presentation1").Variant);
			presentation.callMethod("SaveAs", new Object[]{new JIString("C:\\temp\\presentation1.ppt").Variant,JIVariant.OPTIONAL_PARAM(),new Integer(-1)});
			Thread.sleep(3000);
			presentation.callMethod("Close");
		}
		else
		{
			textrange.put("Text",new JIString("Presentation2").Variant);
			slides.callMethod("InsertFromFile", new Object[]{new JIString("C:\\temp\\presentation1.ppt"),new Integer(1), new Integer(1), new Integer(1)});
			presentation.callMethod("SaveAs", new Object[]{new JIString("C:\\temp\\presentation2.ppt"),JIVariant.OPTIONAL_PARAM(),new Integer(-1)});
			Thread.sleep(3000);
			presentation.callMethod("Close");

			dispatch.callMethod("Quit");
		}


	}

	JISession.destroySession(dispatch.getAssociatedSession());
}
 
开发者ID:howie,项目名称:jinterop,代码行数:64,代码来源:MSPowerPoint.java

示例10: performOp

import org.jinterop.dcom.impls.automation.IJIDispatch; //导入方法依赖的package包/类
public void performOp() throws JIException, InterruptedException {

		/* JISystem config *
		 *
		 */
		JISystem.setJavaCoClassAutoCollection(true);



		System.out.println(((JIVariant) dispatch.get("Version")).getObjectAsString().getString());
		System.out.println(((JIVariant) dispatch.get("Path")).getObjectAsString().getString());
		JIVariant variant = dispatch.get("Documents");

		System.out.println("Open document...");
		IJIDispatch documents = (IJIDispatch) JIObjectFactory.narrowObject(variant.getObjectAsComObject());
		JIString filePath = new JIString("c:\\temp\\test.doc");
		JIVariant variant2[] = documents.callMethodA("open", new Object[] { filePath, JIVariant.OPTIONAL_PARAM(), JIVariant.OPTIONAL_PARAM(), JIVariant.OPTIONAL_PARAM() ,JIVariant.OPTIONAL_PARAM() ,JIVariant.OPTIONAL_PARAM() ,JIVariant.OPTIONAL_PARAM() ,JIVariant.OPTIONAL_PARAM() ,JIVariant.OPTIONAL_PARAM() ,JIVariant.OPTIONAL_PARAM() ,JIVariant.OPTIONAL_PARAM() ,JIVariant.OPTIONAL_PARAM() ,JIVariant.OPTIONAL_PARAM() ,JIVariant.OPTIONAL_PARAM() , JIVariant.OPTIONAL_PARAM() });

		System.out.println("doc opened");
		//10
		sleep(10);

		System.out.println("Get content...");
		IJIDispatch document = (IJIDispatch) JIObjectFactory.narrowObject(variant2[0].getObjectAsComObject());
		variant = document.get("Content");
		IJIDispatch range = (IJIDispatch) JIObjectFactory.narrowObject(variant.getObjectAsComObject());

		//10
		sleep(10);
		System.out.println("Running find...");
		variant = range.get("Find");
		IJIDispatch find = (IJIDispatch) JIObjectFactory.narrowObject(variant.getObjectAsComObject());

		//2
		sleep(5);

		System.out.println("Running execute...");
		JIString findString = new JIString("ow");
		JIString replaceString = new JIString("igh");
		find.callMethodA("Execute", new Object[] { findString.VariantByRef, JIVariant.OPTIONAL_PARAM(), JIVariant.OPTIONAL_PARAM(), JIVariant.OPTIONAL_PARAM(),
				JIVariant.OPTIONAL_PARAM(), JIVariant.OPTIONAL_PARAM(), JIVariant.OPTIONAL_PARAM(), JIVariant.OPTIONAL_PARAM(), JIVariant.OPTIONAL_PARAM(),
				replaceString.VariantByRef, JIVariant.OPTIONAL_PARAM(), JIVariant.OPTIONAL_PARAM(), JIVariant.OPTIONAL_PARAM(), JIVariant.OPTIONAL_PARAM(),
				JIVariant.OPTIONAL_PARAM() });

		//1
		sleep(2);

		System.out.println("Closing document...");
		document.callMethod("Close");

	}
 
开发者ID:howie,项目名称:jinterop,代码行数:52,代码来源:MSWord.java

示例11: performOp

import org.jinterop.dcom.impls.automation.IJIDispatch; //导入方法依赖的package包/类
public void performOp() throws JIException, InterruptedException
{
	unknown = comServer.createInstance();
	dispatch = (IJIDispatch)JIObjectFactory.narrowObject(unknown.queryInterface(IJIDispatch.IID));
	IJITypeInfo typeInfo = dispatch.getTypeInfo(0);
	typeInfo.getFuncDesc(0);

	dispatch.callMethod("Open",new Object[]{new JIString("driver=Microsoft Access Driver (*.mdb);dbq=C:\\temp\\products.mdb"),JIVariant.OPTIONAL_PARAM(),JIVariant.OPTIONAL_PARAM(),new Integer(-1)});

	JIVariant variant[] = dispatch.callMethodA("Execute",new Object[]{new JIString("SELECT * FROM Products"),new Integer(-1)});
	if (variant[0].isNull())
	{
		System.out.println("Recordset is empty.");
	}
	else
	{
		IJIDispatch resultSet = (IJIDispatch)JIObjectFactory.narrowObject(variant[0].getObjectAsComObject());
		//variant = resultSet.get("EOF");
		while(!resultSet.get("EOF").getObjectAsBoolean())
		{
			JIVariant variant2 = resultSet.get("Fields");
			IJIDispatch fields = (IJIDispatch)JIObjectFactory.narrowObject(variant2.getObjectAsComObject());
			int count = fields.get("Count").getObjectAsInt();
			for (int i = 0;i < count;i++)
			{
				variant = fields.get("Item",new Object[]{new Integer(i)});
				IJIDispatch field = (IJIDispatch)JIObjectFactory.narrowObject(variant[0].getObjectAsComObject());
				variant2 = field.get("Value");
				Object val = null;
				if (variant2.getType() == JIVariant.VT_BSTR)
				{
					val = variant2.getObjectAsString().getString();
				}
				if (variant2.getType() == JIVariant.VT_I4)
				{
					val = new Integer(variant2.getObjectAsInt());
				}
				System.out.println(field.get("Name").getObjectAsString().getString() + " = " + val + "[" + variant2.getType() + "]");
			}
			resultSet.callMethod("MoveNext");
		}


	}

	JISession.destroySession(session);
}
 
开发者ID:howie,项目名称:jinterop,代码行数:48,代码来源:MSADO.java


注:本文中的org.jinterop.dcom.impls.automation.IJIDispatch.callMethod方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。