Hi, everyone, how do you set the parameters when using the Msvm_CollectionManagementService::AddMember() function?
According to the MSDN documentation(AddMember), it says: The 'Member' parameter means: A reference to the managed element
to add. The 'Collection' parameter means: A reference to the collection that receives the managed element. I am really Do not understand, how should this parameter be set?
My code snippet:
VARIANT var;
BSTR paramName4 = L"Member";
//var.vt = VT_BYREF | VT_UNKNOWN;
//var.ppunkVal = (IUnknown**)&m_pComputerSystem;
//var.vt = VT_BYREF;
//var.byref = (PVOID)m_pComputerSystem;
//var.vt = VT_UNKNOWN;
//var.punkVal = (IUnknown*)pInClass;
var.vt = VT_BSTR;
var.bstrVal = _bstr_t(_vmName.c_str()); //_vmName, the virtual machine name
hresult = pInClass->Put(paramName4,
0,
&var,
0);
if (FAILED(hresult))
{
string msg = "Failed to set property.";
throw std::exception(msg.c_str());
}
BSTR paramName5 = L"Collection";
//var.vt = VT_BYREF | VT_UNKNOWN;
//var.ppunkVal = (IUnknown**)&collectionName;
//var.vt = VT_BYREF;
//var.byref = (PVOID)collectionName;
//var.vt = VT_UNKNOWN;
//var.punkVal = (IUnknown*)pInClass->QueryInterface(&collectionName);
var.vt = VT_BSTR;
var.bstrVal = _bstr_t(_collectionName.c_str()); // _collectionName, the collection name
//invoke method
hresult = m_pWbemServices->ExecMethod(
var.bstrVal,
methodName2,
0,
NULL,
pInClass,
&pOutClass,
NULL);
if (FAILED(hresult))
{
string msg = "Failed to invoke method.";
throw std::exception(msg.c_str());
}
Next I call the AddMember() method and the CreateSnapshot() method, and the return value is S_OK, but unfortunately, I don't see the new snapshot generation or .rct file generation.
Please give me some guidance, cheers