diff options
| -rw-r--r-- | windns/src/windns/dnshelpers.cpp | 30 | ||||
| -rw-r--r-- | windns/src/windns/dnshelpers.h | 20 |
2 files changed, 50 insertions, 0 deletions
diff --git a/windns/src/windns/dnshelpers.cpp b/windns/src/windns/dnshelpers.cpp new file mode 100644 index 0000000000..a23ffc5cef --- /dev/null +++ b/windns/src/windns/dnshelpers.cpp @@ -0,0 +1,30 @@ +#include "stdafx.h" +#include "dnshelpers.h" +#include "comhelpers.h" + +namespace dnshelpers +{ + +std::wstring GetId(CComPtr<IWbemClassObject> instance) +{ + return ComConvertString(V_BSTR(&ComGetPropertyAlways(instance, L"SettingID"))); +} + +OptionalStringList GetServers(CComPtr<IWbemClassObject> instance) +{ + OptionalStringList result; + + auto servers = ComGetProperty(instance, L"DNSServerSearchOrder"); + + if (VT_EMPTY == V_VT(&servers) || VT_NULL == V_VT(&servers)) + { + return result; + } + + result = std::make_unique<std::vector<std::wstring> >( + ComConvertStringArray(V_ARRAY(&servers))); + + return result; +} + +} diff --git a/windns/src/windns/dnshelpers.h b/windns/src/windns/dnshelpers.h new file mode 100644 index 0000000000..036fb032b1 --- /dev/null +++ b/windns/src/windns/dnshelpers.h @@ -0,0 +1,20 @@ +#pragma once + +#include <string> +#include <memory> +#include <vector> +#include <atlbase.h> +#include <wbemidl.h> + +namespace dnshelpers +{ + +// instance = Win32_NetworkAdapterConfiguration +std::wstring GetId(CComPtr<IWbemClassObject> instance); + +using OptionalStringList = std::unique_ptr<std::vector<std::wstring> >; + +// instance = Win32_NetworkAdapterConfiguration +OptionalStringList GetServers(CComPtr<IWbemClassObject> instance); + +}
\ No newline at end of file |
