Search code examples
c++wifiwlanapi

How to use WlanRegisterNotification function


I want to register wlan notification.

Code:

HANDLE hClient;
DWORD dwResult = 0;
DWORD dwPrevNotif = 0;

dwResult = WlanRegisterNotification(hClient, WLAN_NOTIFICATION_SOURCE_ALL, TRUE, NotificationCallback, NULL, NULL, &dwPrevNotif);

void WINAPI WirelessConnect::NotificationCallback(PWLAN_NOTIFICATION_DATA wlanData, PVOID context)
{

}

The problem is:

error: C3867: 'WirelessConnect::NotificationCallback': non-standard syntax; use '&' to create a pointer to member

When I use &NotificationCallback I get error:

error: C2276: '&': illegal operation on bound member function expression

How to fix it? Thanks.


Solution

  • You are trying to pass a pointer to a member function as a callback, that is - as a function pointer. You shouldn't do that, member function pointers are meaningless without the object itself.

    You should make your callback a static function, that way there are no objects involved.