⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wmiclientrep.cpp

📁 Pegasus is an open-source implementationof the DMTF CIM and WBEM standards. It is designed to be por
💻 CPP
📖 第 1 页 / 共 2 页
字号:
///////////////////////////////////////////////////////////////////////////////Array<CIMObjectPath> WMIClientRep::enumerateInstanceNames(    const CIMNamespaceName& nameSpace,    const CIMName& className){	Array<CIMObjectPath> instanceNames;	CIMException cimException;		try	{		//Initializes the WMI Provider Interface    	WMIInstanceProvider provider;		provider.initialize(TRUE);		//Performs the WMI call		instanceNames = provider.enumerateInstanceNames(			nameSpace.getString(),			String::EMPTY,			String::EMPTY,			className.getString());		//terminate the provider		provider.terminate();	}	catch(CIMException&)	{		throw;	}	catch(Exception& exception)	{	   cimException = PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, exception.getMessage());	   throw cimException;	}	catch(...)	{		cimException = PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, "enumerateInstanceNames() failed!");		throw cimException;	}	return(instanceNames);}///////////////////////////////////////////////////////////////////////////////Array<CIMObject> WMIClientRep::execQuery(    const CIMNamespaceName& nameSpace,    const String& queryLanguage,    const String& query){    Array<CIMObject> cimObjects;	CIMException cimException;		try	{		//Initializes the WMI Provider Interface    	WMIQueryProvider provider;		provider.initialize(TRUE);		//Performs the WMI call		cimObjects = provider.execQuery(			nameSpace.getString(),			String::EMPTY,			String::EMPTY,			queryLanguage,			query);		//terminate the provider		provider.terminate();	}	catch(CIMException&)	{		throw;	}	catch(Exception& exception)	{	   cimException = PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, exception.getMessage());	   throw cimException;	}	catch(...)	{		cimException = PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, "execQuery() failed!");		throw cimException;	}	return(cimObjects);}///////////////////////////////////////////////////////////////////////////////Array<CIMObject> WMIClientRep::associators(    const CIMNamespaceName& nameSpace,    const CIMObjectPath& objectName,    const CIMName& assocClass,    const CIMName& resultClass,    const String& role,    const String& resultRole,    Boolean includeQualifiers,    Boolean includeClassOrigin,    const CIMPropertyList& propertyList){	Array<CIMObject> cimObjects;	CIMPropertyList myPropertyList(propertyList);	CIMException cimException;		try	{		//Initializes the WMI Provider Interface    	WMIAssociatorProvider provider;		provider.initialize(TRUE);		//Performs the WMI call		cimObjects = provider.associators(			nameSpace.getString(),			String::EMPTY,			String::EMPTY,			objectName,			assocClass.getString(),			resultClass.getString(),			role,			resultRole,			includeQualifiers,			includeClassOrigin,			myPropertyList);		//terminate the provider		provider.terminate();	}	catch(CIMException&)	{		throw;	}	catch(Exception& exception)	{	   cimException = PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, exception.getMessage());	   throw cimException;	}	catch(...)	{		cimException = PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, "associators() failed!");		throw cimException;	}	return(cimObjects);}///////////////////////////////////////////////////////////////////////////////Array<CIMObjectPath> WMIClientRep::associatorNames(    const CIMNamespaceName& nameSpace,    const CIMObjectPath& objectName,    const CIMName& assocClass,    const CIMName& resultClass,    const String& role,    const String& resultRole){	Array<CIMObjectPath> objectNames;	CIMException cimException;		try	{		//Initializes the WMI Provider Interface    	WMIAssociatorProvider provider;		provider.initialize(TRUE);		//Performs the WMI call		objectNames = provider.associatorNames(			nameSpace.getString(),			String::EMPTY,			String::EMPTY,			objectName,			assocClass.getString(),			resultClass.getString(),			role,			resultRole);		//terminate the provider		provider.terminate();	}	catch(CIMException&)	{		throw;	}	catch(Exception& exception)	{	   cimException = PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, exception.getMessage());	   throw cimException;	}	catch(...)	{		cimException = PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, "associatorNames() failed!");		throw cimException;	}	return(objectNames);}///////////////////////////////////////////////////////////////////////////////Array<CIMObject> WMIClientRep::references(    const CIMNamespaceName& nameSpace,    const CIMObjectPath& objectName,    const CIMName& resultClass,    const String& role,    Boolean includeQualifiers,    Boolean includeClassOrigin,    const CIMPropertyList& propertyList){    Array<CIMObject> cimObjects;	CIMPropertyList myPropertyList(propertyList);	CIMException cimException;		try	{		//Initializes the WMI Provider Interface    	WMIReferenceProvider provider;		provider.initialize(TRUE);		//Performs the WMI call		cimObjects = provider.references(			nameSpace.getString(),			String::EMPTY,			String::EMPTY,			objectName,			resultClass.getString(),			role,			includeQualifiers,			includeClassOrigin,			myPropertyList);		//terminate the provider		provider.terminate();	}	catch(CIMException&)	{		throw;	}	catch(Exception& exception)	{	   cimException = PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, exception.getMessage());	   throw cimException;	}	catch(...)	{		cimException = PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, "references() failed!");		throw cimException;	}	return(cimObjects);}///////////////////////////////////////////////////////////////////////////////Array<CIMObjectPath> WMIClientRep::referenceNames(    const CIMNamespaceName& nameSpace,    const CIMObjectPath& objectName,    const CIMName& resultClass,    const String& role){    Array<CIMObjectPath> objectNames;	CIMException cimException;		try	{		//Initializes the WMI Provider Interface    	WMIReferenceProvider provider;		provider.initialize(TRUE);		//Performs the WMI call		objectNames = provider.referenceNames(			nameSpace.getString(),			String::EMPTY,			String::EMPTY,			objectName,			resultClass.getString(),			role);		//terminate the provider		provider.terminate();	}	catch(CIMException&)	{		throw;	}	catch(Exception& exception)	{	   cimException = PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, exception.getMessage());	   throw cimException;	}	catch(...)	{		cimException = PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, "referenceNames() failed!");		throw cimException;	}	return(objectNames);}///////////////////////////////////////////////////////////////////////////////CIMValue WMIClientRep::getProperty(    const CIMNamespaceName& nameSpace,    const CIMObjectPath& instanceName,    const CIMName& propertyName){    CIMValue value;	CIMException cimException;		try	{		//Initializes the WMI Provider Interface    	WMIInstanceProvider provider;		provider.initialize(TRUE);		//Performs the WMI call		value = provider.getProperty(			nameSpace.getString(),			String::EMPTY,			String::EMPTY,			instanceName,			propertyName.getString());		//terminate the provider		provider.terminate();	}	catch(CIMException&)	{		throw;	}	catch(Exception& exception)	{	   cimException = PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, exception.getMessage());	   throw cimException;	}	catch(...)	{		cimException = PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, "getProperty() failed!");		throw cimException;	}	return(value);}///////////////////////////////////////////////////////////////////////////////void WMIClientRep::setProperty(    const CIMNamespaceName& nameSpace,    const CIMObjectPath& instanceName,    const CIMName& propertyName,    const CIMValue& newValue){    CIMException cimException;	try	{		//Initializes the WMI Provider Interface    	WMIInstanceProvider provider;		provider.initialize(TRUE);		//Performs the WMI call		provider.setProperty(			nameSpace.getString(),			String::EMPTY,			String::EMPTY,			instanceName,			propertyName.getString(),			newValue);		//terminate the provider		provider.terminate();	}	catch(CIMException&)	{		throw;	}	catch(Exception& exception)	{	   cimException = PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, exception.getMessage());	   throw cimException;	}	catch(...)	{		cimException = PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, "setProperty() failed!");		throw cimException;	}}///////////////////////////////////////////////////////////////////////////////CIMQualifierDecl WMIClientRep::getQualifier(    const CIMNamespaceName& nameSpace,    const CIMName& qualifierName){    CIMQualifierDecl cimQualifierDecl;	CIMException cimException;	try	{		//Initializes the WMI Provider Interface    	WMIQualifierProvider provider;		provider.initialize(TRUE);		//Performs the WMI call		cimQualifierDecl = provider.getQualifier(			nameSpace.getString(),			String::EMPTY,			String::EMPTY,			qualifierName.getString());		//terminate the provider		provider.terminate();	}	catch(CIMException&)	{		throw;	}	catch(Exception& exception)	{	   cimException = PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, exception.getMessage());	   throw cimException;	}	catch(...)	{		cimException = PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, "getQualifier() failed!");		throw cimException;	}	return(cimQualifierDecl);}///////////////////////////////////////////////////////////////////////////////void WMIClientRep::setQualifier(    const CIMNamespaceName& nameSpace,    const CIMQualifierDecl& qualifierDeclaration){    CIMException cimException;	try	{		//Initializes the WMI Provider Interface    	WMIQualifierProvider provider;		provider.initialize(TRUE);		//Performs the WMI call		provider.setQualifier(			nameSpace.getString(),			String::EMPTY,			String::EMPTY,			qualifierDeclaration);		//terminate the provider		provider.terminate();	}	catch(CIMException&)	{		throw;	}	catch(Exception& exception)	{	   cimException = PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, exception.getMessage());	   throw cimException;	}	catch(...)	{		cimException = PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, "setQualifier() failed!");		throw cimException;	}}///////////////////////////////////////////////////////////////////////////////void WMIClientRep::deleteQualifier(    const CIMNamespaceName& nameSpace,    const CIMName& qualifierName){	CIMException cimException;	try	{		//Initializes the WMI Provider Interface    	WMIQualifierProvider provider;		provider.initialize(TRUE);		//Performs the WMI call		provider.deleteQualifier(			nameSpace.getString(),			String::EMPTY,			String::EMPTY,			qualifierName.getString());		//terminate the provider		provider.terminate();	}	catch(CIMException&)	{		throw;	}	catch(Exception& exception)	{	   cimException = PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, exception.getMessage());	   throw cimException;	}	catch(...)	{		cimException = PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, "deleteQualifier() failed!");		throw cimException;	}}///////////////////////////////////////////////////////////////////////////////Array<CIMQualifierDecl> WMIClientRep::enumerateQualifiers(    const CIMNamespaceName& nameSpace){	Array<CIMQualifierDecl> qualifierDeclarations;	CIMException cimException;	try	{		//Initializes the WMI Provider Interface    	WMIQualifierProvider provider;		provider.initialize(TRUE);		//Performs the WMI call		qualifierDeclarations = provider.enumerateQualifiers(			nameSpace.getString(),			String::EMPTY,			String::EMPTY);		//terminate the provider		provider.terminate();	}	catch(CIMException&)	{		throw;	}	catch(Exception& exception)	{	   cimException = PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, exception.getMessage());	   throw cimException;	}	catch(...)	{		cimException = PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, "enumerateQualifiers() failed!");		throw cimException;	}	return(qualifierDeclarations);}///////////////////////////////////////////////////////////////////////////////CIMValue WMIClientRep::invokeMethod(    const CIMNamespaceName& nameSpace,    const CIMObjectPath& instanceName,    const CIMName& methodName,    const Array<CIMParamValue>& inParameters,    Array<CIMParamValue>& outParameters){    CIMValue retValue;	CIMException cimException;	try	{		//Initializes the WMI Provider Interface    	WMIMethodProvider provider;		provider.initialize(TRUE);		//Performs the WMI call		retValue = provider.invokeMethod(			nameSpace.getString(),			String::EMPTY,			String::EMPTY,			instanceName,			methodName.getString(),			inParameters,			outParameters);		//terminate the provider		provider.terminate();	}	catch(CIMException&)	{		throw;	}	catch(Exception& exception)	{	   cimException = PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, exception.getMessage());	   throw cimException;	}	catch(...)	{		cimException = PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, "invokeMethod() failed!");		throw cimException;	}	return(retValue);}PEGASUS_NAMESPACE_END

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -