title: C++ Builder WMI : Invalid Query
body: <p>Using C++ Builder XE4, I am trying to read Win32_DiskDrive Information, but I am not successful.</p>
  
  <pre><code>    UnicodeString s;
      Variant vX, vY, vZ, vi;
  
      vX = Variant::CreateObject(L"WbemScripting.SWbemLocator");
      vY = vX.OleFunction(L"ConnectServer");
      vZ = vY.OleFunction(L"ExecQuery", L"SELECT * FROM Win32_DiskDrive");
      int n = vZ.OlePropertyGet(L"Count");  // Error
      s.SetLength(0);
      for (int i = 0; i &lt; n; i++) {
          vi = vZ.OleFunction&lt;int&gt;(L"ItemIndex", i);
          s = vi.OlePropertyGet(L"Caption");
          RichEdit1-&gt;Lines-&gt;Add(s);
      }
  </code></pre>
  
  <p>I received Error Message "Invalid Query" at</p>
  
  <pre><code>    int n = vZ.OlePropertyGet(L"Count");  // Error
  </code></pre>
  
  <p>When I check the vZ, the IDE shows "{ { } }". Does this mean that I made mistake at getting vZ or somewhere before?</p>
  
  <p>My environment is Windows7 Professional. </p>
  
  <p>Any correction on the above code will be helpful.</p>