none
VC++ - Set input parameters for "GetSummaryInformation" method of "Msvm_VirtualSystemManagementService" RRS feed

  • Question

  • Hi,

    I want guest OS name of all running VMs on my hyper-V server.
    I am using VC++ to achieve my task.

    Following steps completed successfully.

    1.CoInitializeEx
    2.CoInitializeSecurity
    3.CoCreateInstance
    4.ConnectServer
    5.CoSetProxyBlanket
    6.GetObject of class "Msvm_VirtualSystemManagementService"
    7.GetMethod "GetSummaryInformation"
    8.SpawnInstance

    Now how to set input parameters for "GetSummaryInformation" & call "ExecMethod" for the same.
    I don't get any idea from C# code sample.

    Code snippet after "SpawnInstance"
    ------------------------------------------

    SAFEARRAYBOUND sab[1];
    sab[0].cElements = 1;
    sab[0].lLbound = 0;

    LONG i = 0;
    LONG val = 106; // guest operating system
           
            VARIANT var1;
            var1.vt = VT_ARRAY | VT_I4;
            var1.parray = SafeArrayCreate(VT_I4, 1, sab);
            SafeArrayPutElement(var1.parray, &i, &val);

            hres = pClassInstance->Put(L"RequestedInformation", 0, &var1, 0);
            if(FAILED(hres))
            {
                printf("FAILED with Status = 0x%08x\n", hres);
                goto exit;                           
            }   
            else{
                printf("Success put 2\n");
            }

            // I want to know how to set "SettingData" parameter

            hres = pClassInstance->Put(L"SettingData", 0, NULL, 0);
            if(FAILED(hres))
            {
                printf("FAILED with Status = 0x%08x\n", hres);
                goto exit;                           
            }
            else{
                printf("Success put\n");
            }
           


            // Execute Method
            IWbemClassObject* pOutParams = NULL;       

            // It gives the error here
            hres = wbemServices->ExecMethod(ClassName, MethodName, 0,
            NULL, pClassInstance, &pOutParams, NULL);

          

    Thanks,
    D V





    Wednesday, April 15, 2009 1:15 PM