2025-04-27 07:49:33 -04:00

907 lines
29 KiB
HTML

<html><head>
<title>WMI Instance Provider Wizard</title>
<style type="text/css">@import "..\..\..\..\..\1033\styles.css";
</style>
</head>
<body onkeydown=OnKey(); style="OVERFLOW: visible" bottomMargin=0
bgColor=#ebebeb leftMargin=0 topMargin=0 onload=InitDocument(document);
rightMargin=0>
<TABLE height="100%" cellSpacing=0 cellPadding=0 width="100%">
<TR align=top>
<TD height="100%">
<TABLE bgcolor="white" style="width:100%;height:65;border-style:solid;border-color:silver;border-width:1;" align=top>
<TR>
<TD>
<DIV>
<P class="titleText">WMI Instance Provider Wizard</P>
<P class="titleDesc">Specify...</P>
</DIV>
</TD>
<TD>
<DIV id="Layer1" style="z-index:1" align=right>
<IMG src="..\..\Images\Overview.bmp" width="92" height="63"></IMG>
</DIV>
</TD>
</TR>
</TABLE>
<TABLE style="BORDER-BOTTOM: silver 1px solid" height="70%" cellSpacing=0
cellPadding=0 width="100%" bgColor=#ebebeb>
<TBODY>
<TR>
<TD style="WIDTH: 187px" vAlign=top align=left>
<TABLE style="WIDTH: 200px; HEIGHT: 280px" align=left
bgColor=#ebebeb>
<TR>
<TD class=bodyText style="HEIGHT: 13%" bgColor=silver
><span class=sideBtn id=Default
onmouseover="this.style.color='blue'; this.style.cursor='hand'"
title="" onclick='Next(document, "default.htm");'
onmouseout="this.style.color='black'"><b
><LABEL for=Default
>Names</LABEL></b></span></TD></TR>
<TR>
<TD class=bodyText style="HEIGHT: 13%" bgColor=#ebebeb
><span class=sideBtn id=WMIClass
onmouseover="this.style.color='blue'; this.style.cursor='hand'"
title="" onclick='Next(document, "WMIClass.htm");'
onmouseout="this.style.color='black'"
><LABEL for=WMIClass
>WMI Class</LABEL></span></TD></TR>
<TR>
<TD class=bodyText style="HEIGHT: 13%" bgColor=silver
><span class=sideBtn id=Attributes
onmouseover="this.style.color='blue'; this.style.cursor='hand'"
title="" onclick='Next(document, "Attributes.htm");'
onmouseout="this.style.color='black'"
><LABEL for=Attributes
>Attributes</LABEL></span></TD></TR>
<!--
<TR>
<TD class=bodyText style="HEIGHT: 13%" bgColor=silver
><span class=sideBtn id=Properties
onmouseover="this.style.color='blue'; this.style.cursor='hand'"
title="" onclick='Next(document, "Properties.htm");'
onmouseout="this.style.color='black'"
><LABEL for=Properties
>Properties</LABEL></SPAN></TD></TR>-->
<TR>
<TD class=bodyText style="HEIGHT: 13%" bgColor=silver
><span></span></TD></TR>
<TR>
<TD class=bodyText style="HEIGHT: 13%" bgColor=silver
><span></span></TD></TR>
<TR>
<TD class=bodyText style="HEIGHT: 13%" bgColor=silver
><span></span></TD></TR>
<TR>
<TD class=bodyText style="HEIGHT: 13%" bgColor=silver
><span></span></TD></TR>
<TR>
<TD class=bodyText style="HEIGHT: 13%" bgColor=silver
><span></span></TD></TR>
</TABLE>
<!-- invisible controls to store ns, classname and methods-->
<input style="display:none" class=itemText id=NAMESPACE name=NAMESPACE> </input>
<input style="display:none" class=itemText id=WMICLASSNAME name=WMICLASSNAME></input>
<input style="display:none" type=radio id=HAS_IMPL_METHODS name=HAS_IMPL_METHODS CHECKED></input>
<table style="HEIGHT: 170px" width="100%" align=center
>
<TBODY>
<tr align=left>
<td>
<p class=itemText style="WIDTH: 234px; HEIGHT: 12px"
><span class=itemText
><b>Select
<u>n</u>amespace:</b></span><br><select
class=itemText id=NSPICKER style="WIDTH: 370px; HEIGHT: 13%"
onchange=OnChangeNS() align=left size=1 name=NSPICKER accessKey=n
TYPE="SELECT-ONE"> <option value=1
selected>root</option></select></SPAN>
</p></td></tr>
<tr>
<td align=left ><br>
<p class=itemText><span class=itemText
><b>Select
c<u>l</u>ass:</b></span><br><input
class=sideBtn onkeypress=OnInputKeyPress()
oncut=OnInputKeyPress() onpaste=OnInputKeyPress()
id=CLASSINPUT style="WIDTH: 369px" name=CLASSINPUT
>
<select class=itemText id=CLASSPICKER
ondblclick=OnClassDblClick()
style="WIDTH: 369px; HEIGHT: 90px"
onchange=OnChangeSelection() align=left size=12
name=CLASSPICKER accessKey=l
TYPE="SELECT-ONE"></select></SPAN></p></td></tr>
<tr align=left>
<td><br>
<span
class=itemText title=""><LABEL
for=CURRENTSELECTION><b
>Current selection:</b><BR> </LABEL>
<TEXTAREA class=itemText id=CURRENTSELECTION style="OVERFLOW: visible; WIDTH: 369px; HEIGHT: 12px" readOnly></TEXTAREA></span>
</td></tr>
</TBODY></table></TD></TR></TBODY></TABLE>
<TABLE style="width:100%;height:10%" cellpadding=0 cellspacing=4>
<TR>
<TD align=left width=85%></TD>
<TD align=right width=5%>
<BUTTON id="HelpBtn" class="buttonClass" ACCESSKEY="h" onClick='window.external.Alert("Sorry, no help is available for this wizard.");'><u>H</u>elp</BUTTON>
</TD>
<TD align=right width=5%>
<BUTTON id="FinishBtn" class="buttonClass" ACCESSKEY="f" onClick='OnFinish(this);'><u>F</u>inish</BUTTON>
</TD>
<TD align=right width=5%>
<BUTTON id="CancelBtn" class="buttonClass" ACCESSKEY="c" onClick='window.external.Finish(document, "cancel");'><u>C</u>ancel</BUTTON>
</TD>
</TR>
</TABLE>
</TD></TR></TABLE>
<SCRIPT language=jscript>
var tab_array = new Array();
tab_array[0] = Default;
tab_array[1] = WMIClass;
tab_array[2] = Attributes;
//tab_array[3] = Properties;
var arCodeComments = new Array();
arCodeComments[0] = "//TODO: put appropriate value here";
arCodeComments[1] = "//check that class name in the path is correct";
arCodeComments[2] = "//create path parser object";
arCodeComments[3] = "";
arCodeComments[4] = "//parse path to find instance for method execution";
arCodeComments[5] = "//Get values of key properties:";
arCodeComments[6] = "//TODO: save vValue for later use";
arCodeComments[7] = "//TODO: iterate through your data source to find the matching object";
arCodeComments[8] = "//Get input arguments:";
arCodeComments[9] = "//TODO: save input parameter value";
arCodeComments[10] = "//The method has no input parameters";
arCodeComments[11] = "//TODO: add code to execute the method here";
arCodeComments[12] = "//get output parameters class";
arCodeComments[13] = "//fill output parameters";
arCodeComments[14] = "//TODO: fill variant with appropriate value";
arCodeComments[15] = "// Send the output object back to the client via the sink";
arCodeComments[16] = "//The method has no output parameters";
arCodeComments[17] = "//Properties of the input parameters object:";
arCodeComments[18] = "//Properties of the output parameters object:";
var locator;
var services;
var classSink = InternalGetObject("WbemScripting.SWbemSink");
var arClassNames;
var dictLookup;
var bRestoreClassSelection;
var bFirstLoad;
var dictCIM2VT = new ActiveXObject("Scripting.Dictionary");
dictCIM2VT.Add("2", "VT_I2"); //wbemCimtypeSint16
dictCIM2VT.Add("3", "VT_I4"); //wbemCimtypeSint32
dictCIM2VT.Add("4", "VT_R4"); //wbemCimtypeReal32
dictCIM2VT.Add("5", "VT_R8"); //wbemCimtypeReal64
dictCIM2VT.Add("8", "VT_BSTR"); //wbemCimtypeString
dictCIM2VT.Add("11", "VT_BOOL"); //wbemCimtypeBoolean
dictCIM2VT.Add("13", "VT_UNKNOWN"); //wbemCimtypeObject
dictCIM2VT.Add("16", "VT_I2"); //wbemCimtypeSint8
dictCIM2VT.Add("17", "VT_UI1"); //wbemCimtypeUint8
dictCIM2VT.Add("18", "VT_I4"); //wbemCimtypeUint16
dictCIM2VT.Add("19", "VT_I4"); //wbemCimtypeUint32
dictCIM2VT.Add("20", "VT_BSTR"); //wbemCimtypeSint64
dictCIM2VT.Add("21", "VT_BSTR"); //wbemCimtypeUint64
dictCIM2VT.Add("101", "VT_BSTR"); //wbemCimtypeDatetime
dictCIM2VT.Add("102", "VT_BSTR"); //wbemCimtypeReference
dictCIM2VT.Add("103", "VT_I2"); //wbemCimtypeChar16
var propPrefix = "s_pProp";
var methPrefix = "s_pMeth";
var inparmPrefix = "s_pIn";
var outparmPrefix = "s_pOut";
function InitDocument(document)
{
try
{
bFirstLoad = window.external.FindSymbol("DOCUMENT_FIRST_LOAD");
if (bFirstLoad)
{
window.external.SetDefaults(document);
}
window.external.Load(document);
locator = InternalGetObject("WbemScripting.SWbemLocator");
EnumNamespaces("root", 1);
CURRENTSELECTION.value = "";
bRestoreClassSelection = true;
//force selection of the last selected namespace and class
//or the first elements in both listboxes
RestoreNSSelection();
OnChangeNS();
}
catch (e)
{
window.external.ReportError("Exception: " + e.description + " in InitDocument()");
}
}
function EnumNamespaces(name, num)
//recursively adds namespaces to the drop-down box
{
try
{
services = locator.ConnectServer("", name);
var instances = new Enumerator(services.InstancesOf("__NAMESPACE"));
for (; !instances.atEnd(); instances.moveNext() )
{
num++;
var oOption = document.createElement("OPTION");
NSPICKER.options.add(oOption);
var NameOut;
if (name != "")
{
NameOut = name + "\\" + instances.item().Name;
}
else
{
NameOut = instances.item().Name;
}
oOption.innerText = NameOut;
oOption.Value = num;
EnumNamespaces(NameOut, num);
}
}
catch (e)
{
window.external.ReportError("Exception: " + e.description + " in EnumNamespaces()");
return;
}
}
function OnChangeNS()
//clear array and dictionary, then call asynchronous class enumeration
{
try
{
//clear CLASSPICKER and CLASSINPUT first
while (CLASSPICKER.options.length > 0)
{
CLASSPICKER.options.remove(0);
}
CLASSINPUT.value = "";
//clear class names array and dictionary
arClassNames = "";
arClassNames = new Array();
dictLookup = "";
dictLookup = new ActiveXObject("Scripting.Dictionary");
//Display "Loading classes..." in the class list box
var oOption = document.createElement("OPTION");
CLASSPICKER.options.add(oOption);
oOption.innerText = "Loading classes...";
oOption.Value = 1;
var strNS = NSPICKER[NSPICKER.selectedIndex].innerText;
services = locator.ConnectServer("", strNS);
document.body.style.cursor = 'wait';
services.SubclassesOfAsync(classSink);
}
catch (e)
{
window.external.ReportError("Exception: " + e.description + " in OnChangeNS()");
}
}
function OnInputKeyPress()
//selects best-matching class in the listbox
{
//update text immediately, without waiting for rather lengthy processing
//CLASSINPUT.value += String.fromCharCode(event.keyCode);
try
{
var strInput = CLASSINPUT.value.toUpperCase();
var bLoopThrough = true;
for (i = 0; i < CLASSPICKER.options.length; i++)
{
var strListed = CLASSPICKER.options[i].innerText.toUpperCase();
if (strListed >= strInput)
{
CLASSPICKER.selectedIndex = i;
bLoopThrough = false;
break;
}
}
if (bLoopThrough)
{
//select the last line
CLASSPICKER.selectedIndex = CLASSPICKER.options.length - 1;
}
//we already updated text, so no need to add the character again:
//event.returnValue=false;
}
catch (e)
{
window.external.ReportError("Exception: " + e.description + " in OnInputKeyPress()");
}
}
function OnChangeSelection()
//display selected value in CLASSINPUT box
{
try
{
if (CLASSPICKER.selectedIndex == -1)
{
return;
}
var selectionValue = CLASSPICKER[CLASSPICKER.selectedIndex].innerText;
//check to see if the selected string is a class name (i.e., appears in the map)
if (!dictLookup.Exists(selectionValue.toUpperCase()))
{
return;
}
CLASSINPUT.value = selectionValue;
}
catch (e)
{
window.external.ReportError("Exception: " + e.description + " in OnChangeSelection");
}
}
function OnClassDblClick()
{
try
{
var selNamespace = NSPICKER[NSPICKER.selectedIndex].innerText;
var selClassName = CLASSPICKER[CLASSPICKER.selectedIndex].innerText;
//see if the class already has a "provider" qualifier and warn
var classObj = services.Get(selClassName);
var strCurrentProv = GetCurrentProviderName(classObj);
if (strCurrentProv != "")
{
var bReplaceProv = confirm ("Warning: this class already has a provider: " +
strCurrentProv + ". Replacing the existing provider could destabilize your system. Are you sure you want to do this?");
if (!bReplaceProv)
{
return;
}
}
var selectionValue = selNamespace + " : " + selClassName;
//check to see if the selected string is a class name (i.e., appears in the map)
if (!dictLookup.Exists(selClassName.toUpperCase()))
return;
CURRENTSELECTION.value = selectionValue;
CURRENTSELECTION.test = "";
NAMESPACE.value = selNamespace;
WMICLASSNAME.value = selClassName;
}
catch(e)
{
window.external.ReportError("Exception: " + e.description + " in OnClassDblClick");
}
}
function Next(document, linkto)
{
GetWMIClassInfo();
bGetClassInfo = true;
window.external.Next(document, linkto);
}
function OnFinish(obj)
{
GetWMIClassInfo();
bGetClassInfo = true;
obj.style.cursor='wait';
window.external.Finish(document, "ok");
}
function InternalGetObject(progID)
{
try
{
var broker = new ActiveXObject("WMIScriptUtils.WMIObjectBroker");
if (broker.CanCreateObject(progID))
{
return broker.CreateObject(progID);
}
else
{
var registrar = new ActiveXObject("WMIScriptUtils.WMIObjectBrokerRegistration");
registrar.Register(progID);
return broker.CreateObject(progID);
}
}
catch (e)
{
window.external.ReportError ("Error in InternalGetObject(): " + e.description);
}
}
function RestoreNSSelection()
{
try
{
//select saved namespace in NSPICKER
for (i = 0; i < NSPICKER.options.length; i++)
{
var strCurrent = NSPICKER.options[i].innerText;
if (strCurrent == NAMESPACE.value)
{
NSPICKER.selectedIndex = i;
//fill CURRENTSELECTION box:
CURRENTSELECTION.value = NAMESPACE.value + " : ";
return;
}
}
//or, just select the first index
NSPICKER.selectedIndex = 0;
}
catch(e)
{
window.external.ReportError ("Error in RestoreNSSelection(): " + e.description);
}
}
function RestoreClassSelection()
{
try
{
var bRestored = false;
//select saved class in CLASSPICKER
for (i = 0; i < CLASSPICKER.options.length; i++)
{
var strCurrent = CLASSPICKER.options[i].innerText;
if (strCurrent == WMICLASSNAME.value)
{
CLASSPICKER.selectedIndex = i;
//fill CURRENTSELECTION box:
CURRENTSELECTION.value += WMICLASSNAME.value;
bRestored = true;
break;
}
}
//or, just select the first index
if (!bRestored)
{
CLASSPICKER.selectedIndex = 0;
}
//update CLASSINPUT
OnChangeSelection();
}
catch(e)
{
window.external.ReportError ("Error in RestoreClassSelection(): " + e.description);
}
}
</SCRIPT>
<script language=JScript>
function classSink::OnObjectReady(objObject, objAsyncContext)
{
//Put each qualifying object's class name into an array (in the uppercase)
//and a dictionary, mapping uppercase and case-preservant names
try
{
//Filter out abstract, system and event classes.
//Luckily, all event classes are abstract :)
if (CheckBoolQualifier(objObject, "abstract") || IsSystem(objObject))
{
return;
}
var NameOut = objObject.Path_.RelPath;
arClassNames[arClassNames.length] = NameOut.toUpperCase();
dictLookup.Add (NameOut.toUpperCase(), NameOut);
}
catch(e)
{
window.external.ReportError("Exception " + e.description + " in OnObjectReady()");
}
}
function classSink::OnCompleted(objObject, objAsyncContext)
{
//sort the uppercase array; pull case-preservant names from the dictionary
//and display them
try
{
//clear "Loading..." text from CLASSPICKER
while (CLASSPICKER.options.length > 0)
{
CLASSPICKER.options.remove(0);
}
arClassNames.sort();
for (i = 0; i < arClassNames.length; i++)
{
var oOption = document.createElement("OPTION");
CLASSPICKER.options.add(oOption);
oOption.innerText = dictLookup.Item(arClassNames[i]);
oOption.Value = i + 1;
}
if (bRestoreClassSelection) //first enumeration after InitDocument()
{
RestoreClassSelection();
bRestoreClassSelection = false;
}
else
{
//force selection of the first class in the list
CLASSPICKER.selectedIndex = 0;
OnChangeSelection();
}
document.body.style.cursor = 'default';
}
catch(e)
{
window.external.ReportError ("Exception " + e.description + " in OnCompleted()");
}
}
function IsSystem(objObject)
{
try
{
var NameOut = objObject.Path_.RelPath;
return (NameOut.slice(0, 2).toString() == "__");
}
catch(e)
{
return false;
}
}
function CheckBoolQualifier (obj, qualName)
{
try
{
var qual = obj.Qualifiers_(qualName);
return (qual.Value);
}
catch(e)
{
//NOTE that if the qualifier is not present, "Not found" will be returned
//Return false in this case
return false;
}
}
function GetCurrentProviderName (obj)
{
//checks if the class already has a "provider" qualifier value and returns it.
//if the class doesn't have a "provider" qualifier or its value is empty, an empty string is
//returned.
try
{
var qual = obj.Qualifiers_("provider");
return (qual.Value.toString());
}
catch(e)
{
//NOTE that if the qualifier is not present, "Not found" will be returned
//Return empty string in this case
return "";
}
}
function GetWMIClassInfo()
{
try
{
if (WMICLASSNAME.value == "")
return;
var strStaticDecls = "";
var strStaticDefs = "";
var strInstancePopulation = "";
var classObj = services.Get(WMICLASSNAME.value);
var props = new Enumerator (classObj.Properties_);
var nKeys = 0;
for (; !props.atEnd(); props.moveNext() )
{
if (CheckBoolQualifier(props.item(), "key"))
nKeys++;
strStaticDecls += "extern const WCHAR * " + propPrefix + props.item().Name + ";\n\r";
strStaticDefs += "const static WCHAR * " + propPrefix + props.item().Name +
" = L\"" + props.item().Name + "\";\n\r";
var vt = dictCIM2VT.Item(props.item().CIMType.toString());
if (props.item().IsArray) {
vt += " | VT_ARRAY";
}
strInstancePopulation += " var.ChangeType(" + vt + ");\n\r";
strInstancePopulation += " //var = <value>; " + arCodeComments[0] + "\n\r";
strInstancePopulation += " hr = pNewInst->Put(CComBSTR(" + propPrefix +
props.item().Name + "), 0, &var, 0);\n\r";
strInstancePopulation += " var.Clear();\n\r\n\r";
}
window.external.AddSymbol("PROPERTY_DEFINITIONS", strStaticDefs);
window.external.AddSymbol("PROPERTY_DECLARATIONS", strStaticDecls);
window.external.AddSymbol("POPULATE_INSTANCE", strInstancePopulation);
window.external.AddSymbol("IS_COMPOUND_KEY", (nKeys > 1).toString());
//find if the object is a singleton
var bSingleton = CheckBoolQualifier(classObj, "Singleton");
window.external.AddSymbol("IS_SINGLETON", bSingleton);
GetMethodInfo(classObj);
}
catch(e)
{
window.external.ReportError ("Error in GetWMIClassInfo():" + e);
}
}
function GetMethodInfo(classObj)
{
try
{
if (WMICLASSNAME.value == "")
return;
var strMethDeclarations = "";
var strMethDefinitions = "";
var strExecMethodBody = "";
//find if the object has any methods
var eMeths = new Enumerator (classObj.Methods_);
var bStatic, bImplemented, bSingleton;
strExecMethodBody += " " + arCodeComments[1] + "\n\r";
strExecMethodBody += " " + arCodeComments[2] + "\n\r";
strExecMethodBody += " CComPtr<IWbemPath>pPath;\n\r";
strExecMethodBody += " hr = m_pPathFactory->CreateInstance(NULL,\n\r" +
" IID_IWbemPath,\n\r" +
" (void **) &pPath);\n\r";
strExecMethodBody += " if (FAILED(hr))\n\r {\n\r return WBEM_E_FAILED;\n\r }\n\r"
strExecMethodBody += " hr = pPath->SetText(WBEMPATH_CREATE_ACCEPT_ALL, strObjectPath);\n\r";
strExecMethodBody += " long nPathLen = CComBSTR(strObjectPath).Length();\n\r";
strExecMethodBody += " ULONG ulBufLen = nPathLen;\n\r";
strExecMethodBody += " WCHAR * wClass = new WCHAR[nPathLen];\n\r";
strExecMethodBody += " if (NULL == wClass)\n\r {\n\r return WBEM_E_OUT_OF_MEMORY;\n\r }\n\r";
strExecMethodBody += " pPath->GetClassName(&ulBufLen, wClass);\n\r";
strExecMethodBody += " if ( _wcsicmp(s_pMyClassName, wClass))\n\r {\n\r";
strExecMethodBody += " delete[] wClass;\n\r";
strExecMethodBody += " return WBEM_E_INVALID_PARAMETER;\n\r\ }\n\r";
strExecMethodBody += " delete[] wClass;\n\r";
for (var nMeths = 0, nImplMeths = 0; !eMeths.atEnd(); eMeths.moveNext(), nMeths++ )
{
strMethDeclarations += "\n\r//" + eMeths.item().Name + "\n\r";
strMethDefinitions += "\n\r//" + eMeths.item().Name + "\n\r";
strMethDeclarations += "extern const WCHAR * " + methPrefix + eMeths.item().Name + ";\n\r";
strMethDefinitions += "const static WCHAR * " + methPrefix + eMeths.item().Name +
" = L\"" + eMeths.item().Name + "\";\n\r";
bImplemented = CheckBoolQualifier(eMeths.item(), "implemented");
if (bImplemented)
nImplMeths++;
else
continue;
bStatic = CheckBoolQualifier(eMeths.item(), "static");
bSingleton = CheckBoolQualifier(classObj, "singleton");
strExecMethodBody += " if (!_wcsicmp (strMethodName, " + methPrefix +
eMeths.item().Name + "))\n\r {\n\r";
if (!bStatic && !bSingleton)
{
strExecMethodBody += " " + arCodeComments[4] + "\n\r";
strExecMethodBody += " CComPtr<IWbemPathKeyList> pIKeyList;\n\r";
strExecMethodBody += " hr = pPath->GetKeyList(&pIKeyList);\n\r";
strExecMethodBody += " if (FAILED(hr))\n\r {\n\r";
strExecMethodBody += " return WBEM_E_INVALID_PARAMETER;\n\r }\n\r";
strExecMethodBody += " ULONG ulNumKeys;\n\r";
strExecMethodBody += " hr = pIKeyList->GetCount(&ulNumKeys);\n\r";
strExecMethodBody += " " + arCodeComments[5] + "\n\r";
strExecMethodBody += " unsigned long uKeyNameBufferSize = nPathLen;\n\r";
strExecMethodBody += " WCHAR * wKeyName = new WCHAR[uKeyNameBufferSize];\n\r";
strExecMethodBody += " if (NULL == wKeyName)\n\r {\n\r return WBEM_E_OUT_OF_MEMORY;\n\r }\n\r";
strExecMethodBody += " CComVariant vValue;\n\r";
strExecMethodBody += " ULONG ulApparentCimType;\n\r";
strExecMethodBody += " for (ULONG i = 0; i < ulNumKeys; i++)\n\r {\n\r";
strExecMethodBody += " hr = pIKeyList->GetKey2(i, 0L, &uKeyNameBufferSize,\n\r";
strExecMethodBody += " wKeyName, &vValue, &ulApparentCimType);\n\r";
strExecMethodBody += " " + arCodeComments[6] + "\n\r }\n\r";
strExecMethodBody += " delete[] wKeyName;\n\r";
strExecMethodBody += " " + arCodeComments[7]+ "\n\r\n\r";
}
strExecMethodBody += " CComVariant var;\n\r";
//enumerate properties of the input parameters object
strMethDeclarations += arCodeComments[17] + "\n\r";
strMethDefinitions += arCodeComments[17] + "\n\r";
var oInParams = eMeths.item().InParameters;
if (oInParams)
{
strExecMethodBody += " " + arCodeComments[8] + "\n\r";
var inParms = new Enumerator (oInParams.Properties_);
for (; !inParms.atEnd(); inParms.moveNext() )
{
strMethDeclarations += "extern const WCHAR * " + inparmPrefix + eMeths.item().Name +
inParms.item().Name + ";\n\r";
strMethDefinitions += "const static WCHAR * " + inparmPrefix + eMeths.item().Name +
inParms.item().Name + " = L\"" + inParms.item().Name + "\";\n\r";
strExecMethodBody += " hr = pInParams->Get(" + inparmPrefix +
eMeths.item().Name + inParms.item().Name +
", 0, &var, NULL, NULL);\n\r";
strExecMethodBody += " " + arCodeComments[9] + "\n\r";
strExecMethodBody += " var.Clear();\n\r\n\r";
}
}
else
{
strExecMethodBody += " " + arCodeComments[10] + "\n\r";
}
strExecMethodBody += " " + arCodeComments[11] + "\n\r\n\r";
//deal with the output parameters object
strMethDeclarations += arCodeComments[18] + "\n\r";
strMethDefinitions += arCodeComments[18] + "\n\r";
var oOutParams = eMeths.item().OutParameters;
if (oOutParams)
{
strExecMethodBody += " " + arCodeComments[12] + "\n\r";
strExecMethodBody += " CComPtr<IWbemClassObject> pOutClass;\n\r";
strExecMethodBody += " hr = m_pClass->GetMethod(" + methPrefix +
eMeths.item().Name +
", 0, NULL, &pOutClass);\n\r";
strExecMethodBody += " CComPtr<IWbemClassObject> pOutParams;\n\r";
strExecMethodBody += " pOutClass->SpawnInstance(0, &pOutParams);\n\r\n\r";
strExecMethodBody += " " + arCodeComments[13] + "\n\r";
var outParms = new Enumerator (oOutParams.Properties_);
for (; !outParms.atEnd(); outParms.moveNext() )
{
strMethDeclarations += "extern const WCHAR * " + outparmPrefix + eMeths.item().Name +
outParms.item().Name + ";\n\r";
strMethDefinitions += "const static WCHAR * " + outparmPrefix + eMeths.item().Name +
outParms.item().Name + " = L\"" + outParms.item().Name + "\";\n\r";
var vt = dictCIM2VT.Item(outParms.item().CIMType.toString());
if (outParms.item().IsArray) {
vt += " | VT_ARRAY";
}
strExecMethodBody += " var.ChangeType(" + vt + ");\n\r";
strExecMethodBody += " " + arCodeComments[14] + "\n\r";
strExecMethodBody += " hr = pOutParams->Put(CComBSTR(" + outparmPrefix +
eMeths.item().Name + outParms.item().Name +
"), 0, &var, 0);\n\r";
strExecMethodBody += " var.Clear();\n\r\n\r";
}
strExecMethodBody += " " + arCodeComments[15] + "\n\r";
strExecMethodBody += " hr = pResponseHandler->Indicate(1, &pOutParams);\n\r\n\r";
}
else
{
strExecMethodBody += " " + arCodeComments[16] + "\n\r\n\r";
}
strExecMethodBody += " pResponseHandler->SetStatus(0, WBEM_S_NO_ERROR, NULL, NULL);\n\r";
strExecMethodBody += " return WBEM_S_NO_ERROR;\n\r";
strExecMethodBody += " }\n\r";
}
strExecMethodBody += " return WBEM_E_NOT_SUPPORTED;\n\r";
//window.external.ReportError (strExecMethodBody);
window.external.AddSymbol("HAS_METHODS", (nMeths > 0).toString());
HAS_IMPL_METHODS.checked = (nImplMeths > 0);
window.external.AddSymbol("PROVIDE_METHODS", HAS_IMPL_METHODS.checked);
window.external.AddSymbol("EXEC_METHOD_BODY", strExecMethodBody);
window.external.AddSymbol("METHOD_DEFINITIONS", strMethDefinitions);
window.external.AddSymbol("METHOD_DECLARATIONS", strMethDeclarations);
}
catch(e)
{
window.external.ReportError ("Error in GetMethodInfo():" + e);
}
}
</script>
</TD></TR></TABLE>
<SCRIPT SRC="..\..\..\..\..\1033\common.js">
</SCRIPT>
</body></html>