<?xml version="1.0"?>
<package>

	<comment>
	QFE COM Input Format Sample for Log Parser 2.2
	</comment>

	<component id="MSUtil.LogQuery.Sample.QFE">
		<?component error="true" debug="true" ?>
		<registration progid="MSUtil.LogQuery.Sample.QFE" classid="{275926B8-2387-4201-ABC3-B8473D7AA677}" description="QFE Input Format" remotable="true" version="1.00">
		</registration>
		<public>

			<method name="OpenInput">
		            	<parameter name="strComputerName"/>
	 		</method>

			<method name="GetFieldCount">
			</method>

			<method name="GetFieldName">
				<parameter name="nFieldIndex"/>
			</method>

			<method name="GetFieldType">
				<parameter name="nFieldIndex"/>
			</method>

			<method name="ReadRecord">
			</method>

			<method name="GetValue">
				<parameter name="nFieldIndex"/>
			</method>

			<method name="CloseInput">
				<parameter name="bAbort"/>
			</method>


			<property name="ExtendedFields">
				<put/>
			</property>
			
		</public>

		<script id="QFE.wsc" language="VBScript">
<![CDATA[

Dim m_objQFEArray
Dim m_nIndex
Dim m_bExtendedFields

m_bExtendedFields = False

Function OpenInput(strComputerName)

	Dim objWMIService
	Dim objQFEs
	Dim nLength
	
	' Default computer name is local machine
	If IsNull(strComputerName) Or Len(strComputerName) = 0 Then
		strComputerName = "."
	End If

	' Query for all the QFE's on the specified machine
	Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputerName & "\root\cimv2")
	Set objQFEs = objWMIService.ExecQuery ("Select * from Win32_QuickFixEngineering")

	' Store in array
	m_objQFEArray = Array()
	For Each objQFE In objQFEs
		ReDim Preserve m_objQFEArray( UBound(m_objQFEArray) + 1 )
		Set m_objQFEArray( UBound(m_objQFEArray) ) = objQFE
	Next

	m_nIndex = LBound(m_objQFEArray)

End Function



Function GetFieldCount()

	' This Input Format returns 4 or 6 fields
	If m_bExtendedFields = True Then
		GetFieldCount = 6
	Else
		GetFieldCount = 4
	End If

End Function



Function GetFieldName(nFieldIndex)

	Select Case nFieldIndex
		Case 0 
			GetFieldName = "QFE"
		Case 1
			GetFieldName = "Description"
		Case 2
			GetFieldName = "InstallDate"
		Case 3
			GetFieldName = "InstalledBy"
		Case 4
			GetFieldName = "Comments"
		Case 5
			GetFieldName = "SP"
	End Select

End Function



Function GetFieldType(nFieldIndex)

	Select Case nFieldIndex
		Case 0 
			' String
			GetFieldType = 3
		Case 1
			' String
			GetFieldType = 3
		Case 2
			' Timestamp
			GetFieldType = 4
		Case 3
			' String
			GetFieldType = 3
		Case 4
			' String
			GetFieldType = 3
		Case 5
			' String
			GetFieldType = 3

	End Select

End Function



Function ReadRecord()

	If m_nIndex >= UBound(m_objQFEArray) Then
		' Enumeration terminated
		ReadRecord = False
	Else
		'Advance
		m_nIndex = m_nIndex + 1
		ReadRecord = True
	End If

End Function



Function GetValue(nFieldIndex)

	Select Case nFieldIndex
		Case 0 
			' QFE
			GetValue = m_objQFEArray(m_nIndex).HotFixID
		Case 1
			' Description
			GetValue = m_objQFEArray(m_nIndex).Description
		Case 2
			' InstallDate
			GetValue = m_objQFEArray(m_nIndex).InstallDate
		Case 3
			' InstalledBy
			GetValue = m_objQFEArray(m_nIndex).InstalledBy
		Case 4
			' Comments
			GetValue = m_objQFEArray(m_nIndex).FixComments
		Case 5
			' SP
			GetValue = m_objQFEArray(m_nIndex).ServicePackInEffect

	End Select	

End Function


Function CloseInput(bAbort)

	m_objQFEArray = Array()

End Function


Function put_ExtendedFields(strValue)

	If UCase(strValue) = "ON" Then
		m_bExtendedFields = True
	Else
		m_bExtendedFields = False
	End If

End Function

]]>
		</script>

	</component>


</package>
