WlanReasonCodeToString function

The WlanReasonCodeToString function retrieves a string that describes a specified reason code.


DWORD WlanReasonCodeToString(
  DWORD  dwReasonCode,
  DWORD  dwBufferSize,
  PWCHAR pStringBuffer,
  PVOID  pReserved



A WLAN_REASON_CODE value of which the string description is requested.


The size of the buffer used to store the string, in WCHAR. If the reason code string is longer than the buffer, it will be truncated and NULL-terminated. If dwBufferSize is larger than the actual amount of memory allocated to pStringBuffer, then an access violation will occur in the calling program.


Pointer to a buffer that will receive the string. The caller must allocate memory to pStringBuffer before calling WlanReasonCodeToString.


Reserved for future use. Must be set to NULL.

Return Value

If the function succeeds, the return value is a pointer to a constant string.

If the function fails, the return value may be one of the following return codes.

Return code Description
A parameter is incorrect. This error is returned if any of the following conditions occur:
  • dwBufferSize is 0.
  • pStringBuffer is NULL.
  • pReserved is not NULL.
Various RPC and other error codes. Use FormatMessage to obtain the message string for the returned error.


Minimum supported client Windows Vista, Windows XP with SP3 [desktop apps only]
Minimum supported server Windows Server 2008 [desktop apps only]
Target Platform Windows
Header wlanapi.h (include Wlanapi.h)
Library Wlanapi.lib
DLL Wlanapi.dll
Redistributable Wireless LAN API for Windows XP with SP2

See Also