Feb 15, 2016 at 6:14am UTC
Hi,
I am trying to use the WMI removeResourceSetting() method of Msvm_VirtualSystemManagementService class to remove the attached disk. To use this method, the first parameter is array of references to instances of the CIM_ResourceAllocationSettingData class.
Here is snippet of code:
saBounds.cElements = 1;
saBounds.lLbound = 0;
psaTokens = SafeArrayCreate(VT_UNKNOWN, 1, &saBounds);
//pinstToken is CComPtr<IWbemClassObject>
//pinstToken is obtained from the query to "Select * from //Mvsm_ResourceAllocationSettingData where..."
pinstToken->QueryInterface(IID_IUnknown, (void**)&pUnknown);
SafeArrayPutElement(psaTokens, &idx, pUnknown);
CComVariant var;
var.vt = VT_ARRAY | VT_UNKNOWN | VT_BYREF;
var.parray = psaTokens;
if we pass on the var parameter to wbem put(string,0,var,0), the method always fails with type mismatch.
What should be the correct variant type that needs to be passed ?
Thanks in adv.
Feb 15, 2016 at 6:15am UTC
Tried with the following but no luck. Any suggestion.
IUnknown *refUnk[1];
refUnk[0] = pUnknown;
SAFEARRAY sfArr;
sfArr.cDims = 1;
sfArr.cbElements = 1;
sfArr.fFeatures = FADF_UNKNOWN | FADF_HAVEIID;
sfArr.pvData = refUnk;
sfArr.rgsabound[0] = saBounds;
sfArr.cLocks = 0;
VariantInit (&avTokens);
V_VT(&avTokens) = VT_ARRAY | VT_UNKNOWN | VT_BYREF;
avTokens.parray = &sfArr;