//配置
WlanHostedNetworkInitSettings
The WlanHostedNetworkInitSettings function configures and persists to storage the network connection settings (SSID and maximum number of peers, for example) on the wireless Hosted Network if these settings are not already configured.
DWORD WINAPI WlanHostedNetworkInitSettings(
_In_ HANDLE hClientHandle,
_Out_opt_ PWLAN_HOSTED_NETWORK_REASON pFailReason,
_Reserved_ PVOID pvReserved
);
WlanHostedNetworkSetProperty
The WlanHostedNetworkSetProperty function sets static properties of the wireless Hosted Network.
DWORD WINAPI WlanHostedNetworkSetProperty(
_In_ HANDLE hClientHandle,
_In_ WLAN_HOSTED_NETWORK_OPCODE OpCode,
_In_ DWORD dwDataSize,
_In_ PVOID pvData,
_Out_opt_ PWLAN_HOSTED_NETWORK_REASON pFailReason,
_Reserved_ PVOID pvReserved
);
WlanHostedNetworkSetSecondaryKey
The WlanHostedNetworkSetSecondaryKey function configures the secondary security key that will be used by the wireless Hosted Network.
DWORD WINAPI WlanHostedNetworkSetSecondaryKey(
_In_ HANDLE hClientHandle,
_In_ DWORD dwKeyLength,
_In_ PUCHAR pucKeyData,
_In_ BOOL bIsPassPhrase,
_In_ BOOL bPersistent,
_Out_opt_ PWLAN_HOSTED_NETWORK_REASON pFailReason,
_Reserved_ PVOID pvReserved
);
//开启AP
WlanHostedNetworkForceStart function
The WlanHostedNetworkForceStart function transitions the wireless Hosted Network to the wlan_hosted_network_active state without associating the request with the application's calling handle.
DWORD WINAPI WlanHostedNetworkForceStart(
_In_ HANDLE hClientHandle,
_Out_opt_ PWLAN_HOSTED_NETWORK_REASON pFailReason,
_Reserved_ PVOID pvReserved
);
//WlanHostedNetworkStartUsing
WlanHostedNetworkStartUsing function
The WlanHostedNetworkStartUsing function starts the wireless Hosted Network.
DWORD WINAPI WlanHostedNetworkStartUsing(
_In_ HANDLE hClientHandle,
_Out_opt_ PWLAN_HOSTED_NETWORK_REASON pFailReason,
_Reserved_ PVOID pvReserved
);
關閉
WlanHostedNetworkForceStop
The WlanHostedNetworkForceStop function transitions the wireless Hosted Network to the wlan_hosted_network_idle without associating the request with the application's calling handle.
DWORD WINAPI WlanHostedNetworkForceStop(
_In_ HANDLE hClientHandle,
_Out_opt_ PWLAN_HOSTED_NETWORK_REASON pFailReason,
_Reserved_ PVOID pvReserved
);
WlanCloseHandle
The WlanCloseHandle function closes a connection to the server.
DWORD WINAPI WlanCloseHandle(
_In_ HANDLE hClientHandle,
_Reserved_ PVOID pReserved
);
首先需要筆記本具備AP熱點功能,記得寫好的程式必須用管理員身分來運作。
準備工作要先做好
如果無法承載於正確的狀態,在支援承載網路的情況下,除了重複開啟外,就是驅動未啟動。
所以要確定 microsoft託管網路虛擬適配器 為啟動狀態。
上面是開啟的一個過程,下面是關閉。開啟後記得關閉,不能開啟再開啟。
上面這種方法就是簡單了,下面用API。
思路都是開啟、設定、關閉三步驟。
第二步:WlanHostedNetworkInitSettings、WlanHostedNetworkSetProperty
第一key是由系統產生的,你就可以不管了,我們需要設定第二keyWlanHostedNetworkSetSecondaryKey,也是我們在使用的密碼。
關閉
忘說了,他們都是Wlanapi.h頭文件的。