//配置
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头文件的。