15extern DWORD (WINAPI *pfnWlanReasonCodeToString)(__in DWORD dwReasonCode, __in DWORD dwBufferSize, __in_ecount(dwBufferSize) PWCHAR pStringBuffer, __reserved PVOID pReserved);
32template<
class _Traits,
class _Ax>
33static DWORD WlanReasonCodeToString(_In_ DWORD dwReasonCode, _Inout_ std::basic_string<wchar_t, _Traits, _Ax> &sValue, __reserved PVOID pReserved)
37 if (!::pfnWlanReasonCodeToString)
38 return ERROR_CALL_NOT_IMPLEMENTED;
43 std::unique_ptr<wchar_t[]> szBuffer(
new wchar_t[dwSize]);
46 DWORD dwResult = ::pfnWlanReasonCodeToString(dwReasonCode, dwSize, szBuffer.get(), pReserved);
47 if (dwResult == ERROR_SUCCESS) {
48 DWORD dwLength = (DWORD)wcsnlen(szBuffer.get(), dwSize);
49 if (dwLength < dwSize - 1) {
51 sValue.assign(szBuffer.get(), dwLength);
111 WlanFreeMemory(_Ptr);
117 template<
class _Other>
120 WlanFreeMemory(_Ptr);
152 bool open(_In_ DWORD dwClientVersion, _Out_ PDWORD pdwNegotiatedVersion)
noexcept
155 const DWORD dwResult = WlanOpenHandle(dwClientVersion, 0, pdwNegotiatedVersion, &h);
156 if (dwResult == ERROR_SUCCESS) {
160 SetLastError(dwResult);
173 WlanCloseHandle(
m_h, NULL);
Base abstract template class to support generic object handle keeping.
Definition: Common.h:604
HANDLE handle_type
Datatype of the object handle this template class handles.
Definition: Common.h:609
void attach(1 handle_type h) noexcept
Sets a new object handle for the class.
Definition: Common.h:818
handle_type m_h
Object handle.
Definition: Common.h:855
WLAN handle wrapper.
Definition: WLAN.h:128
virtual ~wlan_handle()
Closes a connection to the server.
Definition: WLAN.h:137
void free_internal() noexcept override
Closes a connection to the server.
Definition: WLAN.h:171
bool open(1 DWORD dwClientVersion, 1 PDWORD pdwNegotiatedVersion) noexcept
Opens a connection to the server.
Definition: WLAN.h:152
#define WINSTD_HANDLE_IMPL(C, INVAL)
Implements default constructors and operators to prevent their auto-generation by compiler.
Definition: Common.h:162
static const HANDLE invalid
Invalid handle value.
Definition: Common.h:614
WlanFreeMemory_delete()
Default construct.
Definition: WLAN.h:104
void operator()(_Other *) const
Delete a pointer of another type.
Definition: WLAN.h:118
WlanFreeMemory_delete< _Ty > _Myt
This type.
Definition: WLAN.h:99
void operator()(_Ty *_Ptr) const
Delete a pointer.
Definition: WLAN.h:109
Deleter for unique_ptr using WlanFreeMemory.
Definition: WLAN.h:72
WlanFreeMemory_delete()
Default construct.
Definition: WLAN.h:78
void operator()(_Ty *_Ptr) const
Delete a pointer.
Definition: WLAN.h:88
WlanFreeMemory_delete< _Ty > _Myt
This type.
Definition: WLAN.h:73
WlanFreeMemory_delete(const WlanFreeMemory_delete< _Ty2 > &)
Construct from another WlanFreeMemory_delete.
Definition: WLAN.h:83