Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

how to create array of references to instances of the CIM_ResourceAllocationSettingData .

33 views
Skip to first unread message

coolb...@gmail.com

unread,
Feb 10, 2016, 11:48:39 AM2/10/16
to
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(), the method always fails with type mismatch.

What should be the correct variant type that needs to be passed ?


Thanks in advance.
-
Balu

coolb...@gmail.com

unread,
Feb 12, 2016, 4:55:55 AM2/12/16
to
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;
0 new messages