StackExchange / wmi

WMI for Go
http://godoc.org/github.com/StackExchange/wmi
MIT License
436 stars 174 forks source link

SWbemObjectSet does not have ItemIndex on some systems #2

Closed maddyblue closed 8 years ago

maddyblue commented 10 years ago

SWbemObjectSet does not have ItemIndex on my system (windows xp).

// // Dispatch ISWbemObjectSet 0.0: // A collection of Classes or Instances // {76A6415F-CB41-11D1-8B02-00600806D9B6} // 0: QueryInterface(riid _GUID /in/, ppvObj _VT_VOID /out/) VT_VOID 1: AddRef() VT_UI4 2: Release() VT_UI4 3: GetTypeInfoCount(pctinfo _VT_UINT /out/) VT_VOID 4: GetTypeInfo(itinfo VT_UINT /in/, lcid VT_UI4 /in/, pptinfo _VT_VOID /out/) VT_VOID 5: GetIDsOfNames(riid _GUID /in/, rgszNames _VT_I1 /in/, cNames VT_UINT /in/, lcid VT_UI4 /in/, rgdispid _VT_I4 /out/) VT_VOID 6: Invoke(dispidMember VT_I4 /in/, riid GUID /in/, lcid VT_UI4 /in/, wFlags VT_UI2 /in/, pdispparams DISPPARAMS /in/, pvarResult VT_VARIANT /out/, pexcepinfo EXCEPINFO /out/, puArgErr VT_UINT /out/) VT_VOID 7: get _NewEnum() VT_UNKNOWN // Get an Object with a specific path from this collection 8: Item(strObjectPath VT_BSTR /in/, iFlags VT_I4 /_in,opt,def/) ISWbemObject // The number of items in this collection 9: get Count() VTI4 // The Security Configurator for this Object 10: get Security() *ISWbemSecurity

I think you should use _NewEnum instead. But I am not expert.

Above from: https://code.google.com/p/go/issues/detail?id=8293#c8

ahall commented 9 years ago

ItemIndex doesn't exist either on Windows 2003. I'd really like to see this sorted.

ahall commented 9 years ago

This is pending https://github.com/go-ole/go-ole/issues/64 to be sorted as we want to call _NewEnum on the SWbemObjectSet to get the enumerator and then iterate over it. Means we shouldn't need to call the Count method to get the number of items as I've had issues with that on XP.

ahall commented 9 years ago

The issue go-ole/go-ole#64 has now been sorted so this should be fairly easy to implement now.

mayowa commented 9 years ago

Hi, is there anything I can do to help? I know next to nothing about WMI internals but I can help test

ahall commented 8 years ago

Need to merge SokoloffA pull request, it solves this issue.

ahall commented 8 years ago

Should be ok to close this.