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


Java IJIDispatch.get方法代码示例

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


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

示例1: pasteArrayToWorkSheet

import org.jinterop.dcom.impls.automation.IJIDispatch; //导入方法依赖的package包/类
public void pasteArrayToWorkSheet() throws JIException
{
	int dispId = dispatchOfWorkSheet.getIDsOfNames("Range");
	JIVariant variant = new JIVariant(new JIString("A1:C3"));
	Object[] out = new Object[]{JIVariant.class};
	JIVariant[] outVal2 = dispatchOfWorkSheet.get(dispId, new Object[]{variant});
	IJIDispatch dispRange = (IJIDispatch)JIObjectFactory.narrowObject(outVal2[0].getObjectAsComObject());


      JIVariant[][] newValue = {
    	        { new JIVariant(new JIString("defe")), new JIVariant(false), new JIVariant((double)(98765.0 / 12345.0))},
    	        { new JIVariant(new Date()), new JIVariant((int)5454),new JIVariant((float)(22.0 / 7.0) )       },
    	        { new JIVariant(true), new JIVariant(new JIString("dffe")),new JIVariant(new Date())}
    	      };

     // implement safe array XxX dimension

	dispRange.put("Value2", new JIVariant(new JIArray(newValue)));

	try {
		Thread.sleep(10000);
	} catch (InterruptedException e) {
		e.printStackTrace();
	}

	JIVariant variant2 = dispRange.get("Value2");
	JIArray newValue2 = variant2.getObjectAsArray();
	newValue = (JIVariant[][])newValue2.getArrayInstance();
	for(int i = 0; i < newValue.length; i++){
        for(int j = 0; j < newValue[i].length; j++){
          System.out.print(newValue[i][j] + "\t");
        }
        System.out.println();
	}

	dispatchOfWorkBook.callMethod("close",new Object[]{Boolean.FALSE,JIVariant.OPTIONAL_PARAM(),JIVariant.OPTIONAL_PARAM()});
	dispatch.callMethod("Quit");
	JISession.destroySession(session);
}
 
开发者ID:howie,项目名称:jinterop,代码行数:40,代码来源:MSExcel2.java

示例2: performOp

import org.jinterop.dcom.impls.automation.IJIDispatch; //导入方法依赖的package包/类
public void performOp() throws JIException, InterruptedException
	{
//		IJIDispatch securityDisp = (IJIDispatch)JIObjectFactory.narrowObject(dispatch.get("Security_").getObjectAsComObject());
//		securityDisp.put("ImpersonationLevel", new JIVariant(3));
		JIVariant results[] = dispatch.callMethodA("ConnectServer",new Object[]{JIVariant.OPTIONAL_PARAM(),new JIString("ROOT\\CIMV2"),JIVariant.OPTIONAL_PARAM(),JIVariant.OPTIONAL_PARAM()
				,JIVariant.OPTIONAL_PARAM(),JIVariant.OPTIONAL_PARAM(),new Integer(0),JIVariant.OPTIONAL_PARAM()});

		IJIDispatch wbemServices_dispatch = (IJIDispatch)JIObjectFactory.narrowObject((results[0]).getObjectAsComObject());
		results = wbemServices_dispatch.callMethodA("ExecQuery", new Object[]{new JIString("select * from Win32_OperatingSystem where Primary=True"), JIVariant.OPTIONAL_PARAM(), JIVariant.OPTIONAL_PARAM(),JIVariant.OPTIONAL_PARAM()});
		IJIDispatch wbemObjectSet_dispatch = (IJIDispatch)JIObjectFactory.narrowObject((results[0]).getObjectAsComObject());
		JIVariant variant = wbemObjectSet_dispatch.get("_NewEnum");
		IJIComObject object2 = variant.getObjectAsComObject();

		IJIEnumVariant enumVARIANT = (IJIEnumVariant)JIObjectFactory.narrowObject(object2.queryInterface(IJIEnumVariant.IID));

		JIVariant Count = wbemObjectSet_dispatch.get("Count");
		int count = Count.getObjectAsInt();
		for (int i = 0; i < count; i++)
		{
			Object[] values = enumVARIANT.next(1);
			JIArray array = (JIArray)values[0];
			Object[] arrayObj = (Object[])array.getArrayInstance();
			for (int j = 0; j < arrayObj.length; j++)
			{
				IJIDispatch wbemObject_dispatch = (IJIDispatch)JIObjectFactory.narrowObject(((JIVariant)arrayObj[j]).getObjectAsComObject());
				JIVariant variant2 = (JIVariant)(wbemObject_dispatch.callMethodA("GetObjectText_",new Object[]{new Integer(1)}))[0];
				System.out.println(variant2.getObjectAsString().getString());
				System.out.println("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
			}
		}


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

示例3: performOp

import org.jinterop.dcom.impls.automation.IJIDispatch; //导入方法依赖的package包/类
public void performOp() throws JIException, InterruptedException
{
	System.out.println(((JIVariant)dispatch.get("Version")).getObjectAsString().getString());
	System.out.println(((JIVariant)dispatch.get("Path")).getObjectAsString().getString());
	JIVariant variant = dispatch.get("Documents");
	//JIInterfacePointer ptr = variant.getObjectAsInterfacePointer();
	//IJIDispatch documents = (IJIDispatch)JIObjectFactory.createCOMInstance(unknown,ptr);
	IJIDispatch documents = (IJIDispatch)JIObjectFactory.narrowObject(variant.getObjectAsComObject());
	JIString filePath = new JIString("c:/temp/test.doc");
	JIVariant variant2[] = documents.callMethodA("open",new Object[]{filePath.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(),JIVariant.OPTIONAL_PARAM(),JIVariant.OPTIONAL_PARAM(),
			JIVariant.OPTIONAL_PARAM(),JIVariant.OPTIONAL_PARAM(),JIVariant.OPTIONAL_PARAM(),
			JIVariant.OPTIONAL_PARAM(),JIVariant.OPTIONAL_PARAM()});
	//IJIDispatch document = (IJIDispatch)JIObjectFactory.createCOMInstance(unknown,variant2[0].getObjectAsInterfacePointer());
	IJIDispatch document = (IJIDispatch)JIObjectFactory.narrowObject(variant2[0].getObjectAsComObject());
	variant = document.get("Content");
	//IJIDispatch range = (IJIDispatch)JIObjectFactory.createCOMInstance(unknown,variant.getObjectAsInterfacePointer());
	IJIDispatch range = (IJIDispatch)JIObjectFactory.narrowObject(variant.getObjectAsComObject());

	variant = range.get("Find");
	IJIDispatch find = (IJIDispatch)JIObjectFactory.narrowObject(variant.getObjectAsComObject());

	Thread.sleep(2000);
	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()});
	Thread.sleep(5000);

	dispatch.callMethod("Quit", new Object[]{new JIVariant(-1,true),JIVariant.OPTIONAL_PARAM(),JIVariant.OPTIONAL_PARAM()});
	JISession.destroySession(dispatch.getAssociatedSession());
}
 
开发者ID:howie,项目名称:jinterop,代码行数:39,代码来源:MSWord2.java

示例4: pasteStringToWorkSheet

import org.jinterop.dcom.impls.automation.IJIDispatch; //导入方法依赖的package包/类
public void pasteStringToWorkSheet() throws JIException
{
	int dispId = dispatchOfWorkSheet.getIDsOfNames("Range");

	JIVariant variant = new JIVariant(new JIString("A1"));
	Object[] out = new Object[]{JIVariant.class};
	JIVariant outVal,outVal2[] = null;
	outVal2 = dispatchOfWorkSheet.get(dispId, new Object[]{variant});

	IJIDispatch dispRange = (IJIDispatch)JIObjectFactory.narrowObject(outVal2[0].getObjectAsComObject());

	dispId = dispRange.getIDsOfNames("Select");
	out = new Object[]{JIVariant.class};
	outVal = dispRange.get(dispId)  ;

	dispId = dispatchOfWorkBook.getIDsOfNames("ActiveSheet");
	out = new Object[]{JIVariant.class};
	outVal = dispatchOfWorkBook.get(dispId);

	IJIDispatch dispatchActiveSheet = (IJIDispatch)JIObjectFactory.narrowObject(outVal.getObjectAsComObject());
	dispId = dispatchActiveSheet.getIDsOfNames("Paste");
	out = new Object[]{JIVariant.class};
	try{
		outVal = dispatchActiveSheet.callMethodA(dispId);
	}catch(JIException e)
	{
		throw e;
	}
}
 
开发者ID:howie,项目名称:jinterop,代码行数:30,代码来源:MSExcel.java

示例5: createWorkSheet

import org.jinterop.dcom.impls.automation.IJIDispatch; //导入方法依赖的package包/类
public void createWorkSheet() throws JIException
{
	int dispId = dispatch.getIDsOfNames("Workbooks");

	JIVariant outVal = dispatch.get(dispId);

	IJIDispatch dispatchOfWorkBooks =(IJIDispatch)JIObjectFactory.narrowObject(outVal.getObjectAsComObject());


	JIVariant[] outVal2 = dispatchOfWorkBooks.callMethodA("Add",new Object[]{JIVariant.OPTIONAL_PARAM()});
	dispatchOfWorkBook =(IJIDispatch)JIObjectFactory.narrowObject(outVal2[0].getObjectAsComObject());

	outVal = dispatchOfWorkBook.get("Worksheets");

	dispatchOfWorkSheets = (IJIDispatch)JIObjectFactory.narrowObject(outVal.getObjectAsComObject());

	outVal2 = dispatchOfWorkSheets.callMethodA("Add",new Object[]{JIVariant.OPTIONAL_PARAM(),JIVariant.OPTIONAL_PARAM(),JIVariant.OPTIONAL_PARAM(),JIVariant.OPTIONAL_PARAM()});
	dispatchOfWorkSheet =(IJIDispatch)JIObjectFactory.narrowObject(outVal2[0].getObjectAsComObject());
}
 
开发者ID:howie,项目名称:jinterop,代码行数:20,代码来源:MSExcel2.java

示例6: 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

示例7: 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

示例8: openQuery

import org.jinterop.dcom.impls.automation.IJIDispatch; //导入方法依赖的package包/类
/**
 * Execute a WMQ statement
 * and returns the total returned rows count
 * use getNextRow to get next row
 * 
 * @param queryString : WMQ query to run
 * @param onlyMeta : turn to TRUE in order to retrieve only meta
 * 					and ignore data
 * @return total rows count
 * @throws KettleException
 */
private int openQuery(String queryString, boolean onlyMeta) throws KettleException {
	
	try {

		Object[] params = new Object[] { 
				new JIString(this.hostName), 
				new JIString("ROOT\\CIMV2"),
				JIVariant.OPTIONAL_PARAM(), 
				JIVariant.OPTIONAL_PARAM(), 
				JIVariant.OPTIONAL_PARAM(),
				JIVariant.OPTIONAL_PARAM(), 
				new Integer(0), 
				JIVariant.OPTIONAL_PARAM() 
		};
		JIVariant results[] = wbemLocator.callMethodA("ConnectServer", params);
		wbemServices = (IJIDispatch) narrowObject(results[0].getObjectAsComObject());
		
		results = wbemServices.callMethodA("ExecQuery", new Object[]{new JIString(queryString), JIVariant.OPTIONAL_PARAM(), JIVariant.OPTIONAL_PARAM(),JIVariant.OPTIONAL_PARAM()});
		IJIDispatch wbemObjectSet_dispatch = (IJIDispatch) narrowObject((results[0]).getObjectAsComObject());
		JIVariant variant = wbemObjectSet_dispatch.get("_NewEnum");
		IJIComObject object2 = variant.getObjectAsComObject();

		enumVARIANT = (IJIEnumVariant) narrowObject(object2.queryInterface(IJIEnumVariant.IID));
		
		if(!onlyMeta) {
			JIVariant Count = wbemObjectSet_dispatch.get("Count");
			this.rowsCount = Count.getObjectAsInt();
			if(this.rowLimit>0 && this.rowsCount> this.rowLimit) {
				this.rowsCount=this.rowLimit;
			}
			
			if(log.isDetailed()) {
				log.logDetailed(BaseMessages.getString(PKG, "WMIQuery.RowsCount", String.valueOf(this.rowsCount)));
			}
		}
		
		return this.rowsCount;
		
	}catch(Exception e) {
		throw new KettleException (e);
	}
}
 
开发者ID:jjeb,项目名称:kettle-trunk,代码行数:54,代码来源:WMIQuery.java


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