c++ - How to get the object name from GET method of IWbemClassObject class in wmi queries? -


my code following. not able permission on repository.

int cwmiqueries::initwmiqueries() { hresult hres; hres = coinitializeex(0, coinit_multithreaded);  if (failed(hres)) {     cout << "failed initialize com library. "          << "error code = 0x"          << hex << hres << endl;     return 1;              // program has failed. }  // initialize  hres =  coinitializesecurity(     null,          -1,      // com negotiates service                       null,    // authentication services     null,    // reserved     rpc_c_authn_level_default,    // authentication     rpc_c_imp_level_impersonate,  // impersonation     null,             // authentication info      eoac_none,        // additional capabilities     null              // reserved     );   if (failed(hres)) {     cout << "failed initialize security. "          << "error code = 0x"          << hex << hres << endl;     couninitialize();     return 1;          // program has failed. }  // obtain initial locator windows management // on particular host computer. iwbemlocator *ploc = 0;  hres = cocreateinstance(     clsid_wbemlocator,                  0,      clsctx_inproc_server,      iid_iwbemlocator, (lpvoid *) &ploc);  if (failed(hres)) {     cout << "failed create iwbemlocator object. "         << "error code = 0x"         << hex << hres << endl;     couninitialize();     return 1;       // program has failed. }  iwbemservices *psvc = 0;  // connect root\cimv2 namespace // current user , obtain pointer psvc // make iwbemservices calls.  hres = ploc->connectserver(      _bstr_t(l"root\\visualsvn"), // wmi namespace     null,                    // user name     null,                    // user password     0,                       // locale     null,                    // security flags                      0,                       // authority            0,                       // context object     &psvc                    // iwbemservices proxy     );                                if (failed(hres)) {     cout << "could not connect. error code = 0x"          << hex << hres << endl;     ploc->release();          couninitialize();     return 1;                // program has failed. }  cout << "connected root\\visualsvn wmi namespace" << endl;  // set iwbemservices proxy impersonation // of user (client) occurs. hres = cosetproxyblanket(     psvc,                         // proxy set    rpc_c_authn_winnt,            // authentication service    rpc_c_authz_none,             // authorization service    null,                         // server principal name    rpc_c_authn_level_call,       // authentication level    rpc_c_imp_level_impersonate,  // impersonation level    null,                         // client identity     eoac_none                     // proxy capabilities      );  if (failed(hres)) {     cout << "could not set proxy blanket. error code = 0x"           << hex << hres << endl;     psvc->release();     ploc->release();          couninitialize();     return 1;               // program has failed. }   // use iwbemservices pointer make requests of wmi.  // make requests here:  // example, query running processes ienumwbemclassobject* penumerator = null; hres = psvc->execquery(     bstr_t("wql"),      bstr_t("select * visualsvn_securitydescriptor"),     wbem_flag_forward_only | wbem_flag_return_immediately,      null,     &penumerator);  if (failed(hres)) {     cout << "query processes failed. "          << "error code = 0x"           << hex << hres << endl;     psvc->release();     ploc->release();          couninitialize();     return 1;               // program has failed. } else {      iwbemclassobject *pclsobj;     ulong ureturn = 0;      while (penumerator)     {          hres = penumerator->next(wbem_infinite, 1, &pclsobj, &ureturn);          if(0 == ureturn)         {             break;         }      variant vtprop; safearray *psanames = null;  cimtype type; long flavor;      hres = pclsobj->get(l"permissions", 0, &vtprop, &type, &flavor); 

//get methods returing array of object in variant vtprop. not able object idea? have tried not able find object name.

safearray *psafearray = vtprop.parray;  uint ldim = safearraygetdim(psafearray);  long llbound = 0; long lubound = 0; safearraygetlbound(psafearray, 1, &llbound); safearraygetubound(psafearray, 1, &lubound); long ldim3size = lubound - llbound + 1;  (long k = 0; k < ldim3size; k++) {    char* propname1;    hres = safearraygetelement(             psafearray,              &k,              &propname1);   wcout << propname1<< endl;     sysfreestring(propname);   }     variantclear(&vtprop);     }  }  // cleanup // ========  psvc->release(); ploc->release();      couninitialize(); getchar(); return 0;   // program completed. 

}

my question in bold section. way object name variant.


Comments

Popular posts from this blog

c++ - CryptStringToBinary API behavior -

c++ - Correct method for redrawing a layered window -

java.util.scanner - How to read and add only numbers to array from a text file -