//---------------------------------------------------------------------------
#ifndef Unit1H
#define Unit1H
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#define WLAN_REASON_CODE_SUCCESS 0
#define WLAN_MAX_NAME_LENGTH 256
#define DOT11_SSID_MAX_LENGTH 32
#define WLAN_MAX_PHY_TYPE_NUMBER 8
#define WLAN_AVAILABLE_NETWORK_INCLUDE_ALL_ADHOC_PROFILES 0x00000001
#define WLAN_AVAILABLE_NETWORK_INCLUDE_ALL_MANUAL_HIDDEN_PROFILES 0x00000002
#define WLAN_AVAILABLE_NETWORK_CONNECTED 0x00000001
#define WLAN_AVAILABLE_NETWORK_HAS_PROFILE 0x00000002
#define WLAN_NOTIFICATION_SOURCE_ALL 0x0000FFFF
#define WLAN_NOTIFICATION_SOURCE_ONEX 0x00000004
#define WLAN_NOTIFICATION_SOURCE_ACM 0x00000008
#define WLAN_PROFILE_GROUP_POLICY 0x00000001
#define WLAN_PROFILE_USER 0x00000002
#define WLAN_PROFILE_GET_PLAINTEXT_KEY 0x00000004
// the following flags are only used for WlanSaveTemporaryProfile API
#define WLAN_PROFILE_CONNECTION_MODE_SET_BY_CLIENT 0x00010000
#define WLAN_PROFILE_CONNECTION_MODE_AUTO 0x00020000
typedef enum _WLAN_INTERFACE_STATE {
wlan_interface_state_not_ready = 0,
wlan_interface_state_connected = 1,
wlan_interface_state_ad_hoc_network_formed = 2,
wlan_interface_state_disconnecting = 3,
wlan_interface_state_disconnected = 4,
wlan_interface_state_associating = 5,
wlan_interface_state_discovering = 6,
wlan_interface_state_authenticating = 7
} WLAN_INTERFACE_STATE, *PWLAN_INTERFACE_STATE;
typedef enum _DOT11_PHY_TYPE {
dot11_phy_type_unknown = 0,
dot11_phy_type_any = 0,
dot11_phy_type_fhss = 1,
dot11_phy_type_dsss = 2,
dot11_phy_type_irbaseband = 3,
dot11_phy_type_ofdm = 4,
dot11_phy_type_hrdsss = 5,
dot11_phy_type_erp = 6,
dot11_phy_type_ht = 7,
dot11_phy_type_vht = 8,
dot11_phy_type_IHV_start = 0x80000000,
dot11_phy_type_IHV_end = 0xffffffff
} DOT11_PHY_TYPE, *PDOT11_PHY_TYPE;
typedef enum _DOT11_AUTH_ALGORITHM {
DOT11_AUTH_ALGO_80211_OPEN = 1,
DOT11_AUTH_ALGO_80211_SHARED_KEY = 2,
DOT11_AUTH_ALGO_WPA = 3,
DOT11_AUTH_ALGO_WPA_PSK = 4,
DOT11_AUTH_ALGO_WPA_NONE = 5,
DOT11_AUTH_ALGO_RSNA = 6,
DOT11_AUTH_ALGO_RSNA_PSK = 7,
DOT11_AUTH_ALGO_IHV_START = 0x80000000,
DOT11_AUTH_ALGO_IHV_END = 0xffffffff
} DOT11_AUTH_ALGORITHM, *PDOT11_AUTH_ALGORITHM;
typedef enum _DOT11_CIPHER_ALGORITHM {
DOT11_CIPHER_ALGO_NONE = 0x00,
DOT11_CIPHER_ALGO_WEP40 = 0x01,
DOT11_CIPHER_ALGO_TKIP = 0x02,
DOT11_CIPHER_ALGO_CCMP = 0x04,
DOT11_CIPHER_ALGO_WEP104 = 0x05,
DOT11_CIPHER_ALGO_WPA_USE_GROUP = 0x100,
DOT11_CIPHER_ALGO_RSN_USE_GROUP = 0x100,
DOT11_CIPHER_ALGO_WEP = 0x101,
DOT11_CIPHER_ALGO_IHV_START = 0x80000000,
DOT11_CIPHER_ALGO_IHV_END = 0xffffffff
} DOT11_CIPHER_ALGORITHM, *PDOT11_CIPHER_ALGORITHM;
typedef struct _DOT11_SSID {
ULONG uSSIDLength;
UCHAR ucSSID[DOT11_SSID_MAX_LENGTH];
} DOT11_SSID, *PDOT11_SSID;
typedef enum _DOT11_BSS_TYPE {
dot11_BSS_type_infrastructure = 1,
dot11_BSS_type_independent = 2,
dot11_BSS_type_any = 3
} DOT11_BSS_TYPE, *PDOT11_BSS_TYPE;
typedef enum _WLAN_CONNECTION_MODE {
wlan_connection_mode_profile,
wlan_connection_mode_temporary_profile,
wlan_connection_mode_discovery_secure,
wlan_connection_mode_discovery_unsecure,
wlan_connection_mode_auto,
wlan_connection_mode_invalid
} WLAN_CONNECTION_MODE, *PWLAN_CONNECTION_MODE;
typedef DWORD WLAN_REASON_CODE, *PWLAN_REASON_CODE;
//#pragma pack( push )
//#pragma pack( 8 )
typedef struct _WLAN_CONNECTION_NOTIFICATION_DATA {
WLAN_CONNECTION_MODE wlanConnectionMode;
// DWORD wlanConnectionMode;
WCHAR strProfileName[WLAN_MAX_NAME_LENGTH];
DOT11_SSID dot11Ssid;
DOT11_BSS_TYPE dot11BssType;
BOOL bSecurityEnabled;
WLAN_REASON_CODE wlanReasonCode;
DWORD dwFlags;
WCHAR strProfileXml[1];
} WLAN_CONNECTION_NOTIFICATION_DATA, *PWLAN_CONNECTION_NOTIFICATION_DATA;
typedef struct _WLAN_INTERFACE_INFO {
GUID InterfaceGuid;
WCHAR strInterfaceDescription[256];
WLAN_INTERFACE_STATE isState;
} WLAN_INTERFACE_INFO, *PWLAN_INTERFACE_INFO;
typedef struct _WLAN_INTERFACE_INFO_LIST {
DWORD dwNumberOfItems;
DWORD dwIndex;
WLAN_INTERFACE_INFO InterfaceInfo[];
} WLAN_INTERFACE_INFO_LIST, *PWLAN_INTERFACE_INFO_LIST;
typedef struct _WLAN_AVAILABLE_NETWORK {
WCHAR strProfileName[256];
DOT11_SSID dot11Ssid;
DOT11_BSS_TYPE dot11BssType; //DWORD
ULONG uNumberOfBssids;
BOOL bNetworkConnectable;
WLAN_REASON_CODE wlanNotConnectableReason; //DWORD
ULONG uNumberOfPhyTypes;
DOT11_PHY_TYPE dot11PhyTypes[WLAN_MAX_PHY_TYPE_NUMBER]; //DWORD
BOOL bMorePhyTypes;
//WLAN_SIGNAL_QUALITY wlanSignalQuality;
ULONG wlanSignalQuality;
BOOL bSecurityEnabled;
DOT11_AUTH_ALGORITHM dot11DefaultAuthAlgorithm; //DWORD
DOT11_CIPHER_ALGORITHM dot11DefaultCipherAlgorithm; //DWORD
DWORD dwFlags;
DWORD dwReserved;
} WLAN_AVAILABLE_NETWORK, *PWLAN_AVAILABLE_NETWORK;
typedef struct _WLAN_AVAILABLE_NETWORK_LIST {
DWORD dwNumberOfItems;
DWORD dwIndex;
WLAN_AVAILABLE_NETWORK Network[1];
} WLAN_AVAILABLE_NETWORK_LIST, *PWLAN_AVAILABLE_NETWORK_LIST;
typedef struct _NDIS_OBJECT_HEADER {
UCHAR Type;
UCHAR Revision;
USHORT Size;
} NDIS_OBJECT_HEADER, *PNDIS_OBJECT_HEADER;
typedef UCHAR DOT11_MAC_ADDRESS[6];
typedef DOT11_MAC_ADDRESS* PDOT11_MAC_ADDRESS;
typedef struct _DOT11_BSSID_LIST {
NDIS_OBJECT_HEADER Header;
ULONG uNumOfEntries;
ULONG uTotalNumOfEntries;
DOT11_MAC_ADDRESS BSSIDs[1];
} DOT11_BSSID_LIST, *PDOT11_BSSID_LIST;
typedef struct _WLAN_CONNECTION_PARAMETERS {
WLAN_CONNECTION_MODE wlanConnectionMode; //DWORD
LPCWSTR strProfile; //PWCHAR
PDOT11_SSID pDot11Ssid;
PDOT11_BSSID_LIST pDesiredBssidList; //PVOID
DOT11_BSS_TYPE dot11BssType; //DWORD
DWORD dwFlags;
} WLAN_CONNECTION_PARAMETERS, *PWLAN_CONNECTION_PARAMETERS;
typedef struct _WLAN_NOTIFICATION_DATA {
DWORD NotificationSource;
DWORD NotificationCode;
GUID InterfaceGuid;
DWORD dwDataSize;
PVOID pData;
} WLAN_NOTIFICATION_DATA, *PWLAN_NOTIFICATION_DATA;
typedef struct _WLAN_PROFILE_INFO {
WCHAR strProfileName[256];
DWORD dwFlags;
} WLAN_PROFILE_INFO, *PWLAN_PROFILE_INFO;
typedef struct _WLAN_PROFILE_INFO_LIST {
DWORD dwNumberOfItems;
DWORD dwIndex;
WLAN_PROFILE_INFO ProfileInfo[1];
} WLAN_PROFILE_INFO_LIST, *PWLAN_PROFILE_INFO_LIST;
//#pragma pack( pop )
typedef VOID (WINAPI *WLAN_NOTIFICATION_CALLBACK)(PWLAN_NOTIFICATION_DATA data, PVOID context);
typedef DWORD (WINAPI *PWlanOpenHandle)(DWORD dwClientVersion, PVOID pReserved, PDWORD pdwNegotiatedVersion, PHANDLE phClientHandle);
typedef DWORD (WINAPI *PWlanCloseHandle)(HANDLE hClientHandle, PVOID pReserved);
typedef DWORD (WINAPI *PWlanEnumInterfaces)(HANDLE hClientHandle, PVOID pReserved, PWLAN_INTERFACE_INFO_LIST *ppInterfaceList);
typedef DWORD (WINAPI *PWlanGetAvailableNetworkList)(HANDLE hClientHandle, const GUID *pInterfaceGuid, DWORD dwFlags, PVOID pReserved, PWLAN_AVAILABLE_NETWORK_LIST *ppAvailableNetworkList);
typedef PVOID (WINAPI *PWlanAllocateMemory)(DWORD dwMemorySize);
typedef VOID (WINAPI *PWlanFreeMemory)(PVOID pMemory);
typedef DWORD (WINAPI *PWlanConnect)(HANDLE hClientHandle, const GUID *pInterfaceGuid, const PWLAN_CONNECTION_PARAMETERS pConnectionParameters, PVOID pReserved);
typedef DWORD (WINAPI *PWlanDisconnect)(HANDLE hClientHandle, const GUID *pInterfaceGuid, PVOID pReserved);
typedef DWORD (WINAPI *PWlanRegisterNotification)(HANDLE hClientHandle, DWORD dwNotifSource, BOOL bIgnoreDuplicate, WLAN_NOTIFICATION_CALLBACK funcCallback, PVOID pCallbackContext, PVOID pReserved, PDWORD pdwPrevNotifSource);
typedef DWORD (WINAPI *PWlanSetProfile)(HANDLE hClientHandle, const GUID *pInterfaceGuid, DWORD dwFlags, LPCWSTR strProfileXml, LPCWSTR strAllUserProfileSecurity, BOOL bOverwrite, PVOID pReserved, PDWORD dwReasonCode);
typedef DWORD (WINAPI *PWlanDeleteProfile)(HANDLE hClientHandle, const GUID *pInterfaceGuid, LPCWSTR strProfileName, PVOID pReserved);
typedef DWORD (WINAPI *PWlanGetProfile)(HANDLE hClientHandle, const GUID *pInterfaceGuid, LPCWSTR strProfileName, PVOID pReserved, LPWSTR* pstrProfileXml, PDWORD pdwFlags, PDWORD pdwGrantedAccess);
typedef DWORD (WINAPI *PWlanReasonCodeToString)(DWORD dwReasonCode, DWORD dwBufferSize, PWCHAR pStringBuffer, PVOID pReserved);
typedef DWORD (WINAPI *PWlanGetProfileList)(HANDLE hClientHandle, const GUID *pInterfaceGuid, PVOID pReserved, PWLAN_PROFILE_INFO_LIST *ppProfileList);
typedef DWORD (WINAPI *PWlanScan)(HANDLE hClientHandle, const GUID *pInterfaceGuid, PDOT11_SSID pDot11Ssid, PVOID pIeData, PVOID pReserved);
//---------------------------------------------------------------------------
class TForm1 : public TForm
{
__published: // IDE-managed Components
TLabel *Label1;
TLabel *Label2;
TMemo *Memo1;
TButton *Button1;
void __fastcall Button1Click(TObject *Sender);
private: // User declarations
public: // User declarations
__fastcall TForm1(TComponent* Owner);
};
//---------------------------------------------------------------------------
extern PACKAGE TForm1 *Form1;
//---------------------------------------------------------------------------
#endif