tags:

views:

18

answers:

1

I'm using WMI to read DefaultIPGateway on the WMI object Win32_NetworkAdapterConfiguration. The MSDN says it's a "String Array" and visual studio interprets this as a SAFEARRAY on the VARIANT object returned when you query the WMI.

How do you access the information inside the array? How do you convert each element to a wchar* or char*?

Code is appreciated

ps: note that i don't know anything about COM

A: 

Use SafeArrayAccessData to access the array elements. There is a sample snippet in the MSDN Library article for it that also works with strings. The elements should be BSTR, just wcscpy() into a wchar_t[].

Hans Passant