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


Java IJIDispatch.callMethodA方法代码示例

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


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

示例1: execute

import org.jinterop.dcom.impls.automation.IJIDispatch; //导入方法依赖的package包/类
public void execute() throws JIException
{
	unknown = comStub.createInstance();
	//CLSID of IITestCOMServer
	IJIComObject comObject = (IJIComObject)unknown.queryInterface("4AE62432-FD04-4BF9-B8AC-56AA12A47FF9");
	dispatch = (IJIDispatch)JIObjectFactory.narrowObject(comObject.queryInterface(IJIDispatch.IID));

	//Now call via automation
	Object results[] = dispatch.callMethodA("Add",new Object[]{new Integer(1), new Integer(2), new JIVariant(0,true)});
	System.out.println(results[1]);

	//now without automation
	JICallBuilder callObject = new JICallBuilder();
	callObject.setOpnum(1);//obtained from the IDL or TypeLib.
	callObject.addInParamAsInt(1,JIFlags.FLAG_NULL);
	callObject.addInParamAsInt(2,JIFlags.FLAG_NULL);
	callObject.addInParamAsPointer(new JIPointer(new Integer(0)),JIFlags.FLAG_NULL);
	//Since the retval is a top level pointer , it will get replaced with it's base type.
	callObject.addOutParamAsObject(Integer.class,JIFlags.FLAG_NULL);
	results = comObject.call(callObject);
	System.out.println(results[0]);
	JISession.destroySession(dispatch.getAssociatedSession());
}
 
开发者ID:howie,项目名称:jinterop,代码行数:24,代码来源:TestCOMServer.java

示例2: getNextRow

import org.jinterop.dcom.impls.automation.IJIDispatch; //导入方法依赖的package包/类
/**
 * Returns next row data
 * returns null where there is no more row
 * use getNextRow to get next row
 * 
 * @return next row
 * @throws KettleException
 */
public Object[] getNextRow() throws KettleException {
	
	if(this.rowsCount==0) return null;
	
	this.rowProcessed++;
	if(this.rowProcessed>=this.rowsCount) return null;
	
	try {
		
        Object[] values = enumVARIANT.next(1);
        JIArray array = (JIArray)values[0];
        Object[] arrayObj = (Object[])array.getArrayInstance();
       
           IJIDispatch wbemObject_dispatch = (IJIDispatch) narrowObject(((JIVariant)arrayObj[0]).getObjectAsComObject());
           JIVariant variant2 = (JIVariant)(wbemObject_dispatch.callMethodA("GetObjectText_",new Object[]{new Integer(1)}))[0];               
         
           return  getRowData(variant2.getObjectAsString().getString());

	}catch(Exception e) {
		throw new KettleException(e);
	}
}
 
开发者ID:jjeb,项目名称:kettle-trunk,代码行数:31,代码来源:WMIQuery.java

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

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

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

示例6: getRowMeta

import org.jinterop.dcom.impls.automation.IJIDispatch; //导入方法依赖的package包/类
/**
 * Returns Row meta for a WMQ statement
 * 
 * @param queryString : WMQ query to run
 * @return Row meta
 * @throws KettleException
 */
public RowMetaInterface getRowMeta(String queryString) throws KettleException {
	
	
	try {
           RowMetaInterface retval= new RowMeta();
           
		// run WMQ
		openQuery(queryString, true); 
		
		// get first row
		
        Object[] values = enumVARIANT.next(1);
        JIArray array = (JIArray)values[0];
        Object[] arrayObj = (Object[])array.getArrayInstance();
       
           IJIDispatch wbemObject_dispatch = (IJIDispatch) narrowObject(((JIVariant)arrayObj[0]).getObjectAsComObject());
           JIVariant variant2 = (JIVariant)(wbemObject_dispatch.callMethodA("GetObjectText_",new Object[]{new Integer(1)}))[0];
      
           String props[] = variant2.getObjectAsString().getString().split("[\n\r(\r\n)\\n]");                  
           
           for (String s : props) { 
  			if(s.indexOf("=")>0) {
  				String[] vars=s.split("=");
  				ValueMetaInterface v = new ValueMeta(vars[0].trim(), ValueMeta.TYPE_STRING);

  				retval.addValueMeta(v);
  			}
           }
           return retval;
	}catch(Exception e) {
		throw new KettleException(e);
	}
}
 
开发者ID:jjeb,项目名称:kettle-trunk,代码行数:41,代码来源:WMIQuery.java

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

示例8: openPresentation

import org.jinterop.dcom.impls.automation.IJIDispatch; //导入方法依赖的package包/类
public IJIDispatch openPresentation(String fullEscapedPath) throws JIException, InterruptedException
{
	IJIDispatch presentations = (IJIDispatch)JIObjectFactory.narrowObject(dispatch.get("Presentations").getObjectAsComObject());
	JIVariant[] result = presentations.callMethodA("Open",new Object[]{new JIString(fullEscapedPath),JIVariant.OPTIONAL_PARAM(),JIVariant.OPTIONAL_PARAM(),JIVariant.OPTIONAL_PARAM()});
	return (IJIDispatch)JIObjectFactory.narrowObject(result[0].getObjectAsComObject());
}
 
开发者ID:howie,项目名称:jinterop,代码行数:7,代码来源:MSPowerPoint2.java

示例9: doStuff

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

			try {
				JISession session = JISession.createSession( domain, user, password );

				//this.session.setGlobalSocketTimeout( 60000 );

				// by name, requires local access (for registry search), or a populated progIdVsClsidDB.properties
				JIProgId progId = JIProgId.valueOf( comServerName );

				JIComServer baseComServer = new JIComServer( progId, host, session );

				// Do it by clsid
				//JIClsid clsid = JIClsid.valueOf( "76A6415B-CB41-11d1-8B02-00600806D9B6" );
				//clsid.setAutoRegistration( true );
				//baseComServer = new JIComServer( clsid, host, session );

				// I'm not really sure what the deal is with this
				// Create an intermediary instance?
				IJIComObject unknown = baseComServer.createInstance();

				IJIComObject baseComObject = (IJIComObject) unknown.queryInterface( comObjectId );

				IJIDispatch baseDispatch = (IJIDispatch) JIObjectFactory.narrowObject( baseComObject.queryInterface(IJIDispatch.IID) );

				JIVariant connectServer = (JIVariant)
				baseDispatch.callMethodA(
						"ConnectServer"
						, new Object[] {
								new JIString( host )
								, JIVariant.OPTIONAL_PARAM()
								, JIVariant.OPTIONAL_PARAM()
								, JIVariant.OPTIONAL_PARAM()
								, JIVariant.OPTIONAL_PARAM()
								, JIVariant.OPTIONAL_PARAM()
								, new Integer( 0 )
								, JIVariant.OPTIONAL_PARAM()
						}
					) [ 0 ];

				JISession.destroySession( session );
				System.out.println( "doStuff() run complete" );
			}
			catch ( Exception e ) {
				JISystem.getLogger().log( Level.SEVERE, "Caught exception: ", e );
			}
		}
 
开发者ID:howie,项目名称:jinterop,代码行数:48,代码来源:TestJIThreading.java

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

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

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

示例13: 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.callMethodA方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。