I want to read the attributes of IMachine (as specified in SDK for ver. 5.1.8 ) such as name, parent, SessionState etc. and there are well defined functions to get those attributes, such as get_name () to get the name attribute, get_Parent () to get the parent attribute etc. But when I am using some of them I am getting exceptions and for some of them it is working fine. Is there any reason behind this behaviour? Or any input which I am missing, such as machine should be in running state, maybe.
To be more specific, for example I have following piece of code -
Code: Select all
SAFEARRAY *machinesArray = NULL;
HRESULT rc;
SessionState *sstate;
MachineState *mstate;
rc = virtualBox->get_Machines(&machinesArray);
if (SUCCEEDED(rc))
{
IMachine **machines;
rc = SafeArrayAccessData (machinesArray, (void **) &machines);
if (SUCCEEDED(rc))
{
for (ULONG i = 0; i < machinesArray->rgsabound[0].cElements; ++i)
{
rc = machines[i]->get_Name(&str); //works fine
if (SUCCEEDED(rc))
{
machines[i]->get_FirmwareType(ftype); //gives exception
machines[i]->get_Parent(parent); //gives exception
machines[i]->get_SessionState(sstate); //works fine
machines[i]->get_State(mstate); //gives exception
SysFreeString(str);
} //endof if
} //endof for
} //endof if
SafeArrayUnaccessData (machinesArray);
} //endof if
Regards