I want to call CreateSnapshot Method which is a call to provider but I am stuck as I cannot set the input parameter for Snapshot Type which is expected as uint16. This is passed using a Variant. The code snippet is below.
VARIANT var;
VariantInit(&var);
V_VT(&var) = VT_BSTR;
V_BSTR(&var) = SysAllocString(L"32768");
hr = pInParams->Put(L"SnapshotType", 0, &var, CIM_UINT16);
cout << "\nValue Set Is: "<<var.uintVal<<endl;
I am not able to pass the required value. Any points on what I am doing wrong ?
Note: Put method is working fine with HRESULT as 0 but CreateSnapshot is unsuccessful.
EDIT
Msvm_VirtualSystemSnapshotService Class -> CreateSnapshot has the following prototype
uint32 CreateSnapshot(
[in] CIM_ComputerSystem REF AffectedSystem,
[in] string SnapshotSettings,
[in] uint16 SnapshotType,
[in, out] CIM_VirtualSystemSettingData REF ResultingSnapshot,
[out] CIM_ConcreteJob REF Job
);
BSTR paramName3 = L"SnapshotType";
VARIANT var;
var.vt = VT_UI2;
var.iVal = (uint16_t)32768;
hresult = pInClass->Put(paramName3,
0,
&var,
CIM_UINT16);
if (FAILED(hresult))
{
string msg = "Failed to set property.";
throw std::exception(msg.c_str());
}
VariantClear(&var);
as question,convert unit16 to varint and it's work
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.