WMI: How to create array of references ?? RRS feed

  • Question

  • 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 InParams->put(....), the method always fails with type mismatch. 

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

    Thanks in advance. 


    Thursday, February 11, 2016 9:26 AM