In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "how to achieve WIFI sharing tools under VC++ win7". The content of the article is simple and clear, and it is easy to learn and understand. Please follow the editor's ideas to study and learn "how to achieve WIFI sharing tools under VC++ win7".
About Wireless bearer Network
Wireless hosted Network (Wireless Hosted Network) is a WLAN function provided by Windows 7 and Windows Server 2008 R2 with wireless LAN services installed, with two main functions:
First, a physical wireless network card is virtualized into one or more virtual wireless network cards, which is called virtual WiFi.
Second, with the help of wireless network card, the current access network is virtualized into a software-based wireless access point, which is called virtual AP or soft AP.
= the dividing line of all evils =
The project needs to include wlanapi.h header files and wlanapi.lib libraries
Note: test environment win7_64, it is recommended to turn off some security software, (for example, when I forget to turn off comodo when testing, the firewall always rejects connections from other devices).
=
The function is not complex, and the main functions used are as follows
1. Call WlanOpenHandled to get a connection hClientHandle, which is used for all the following operations. Of course, remember to call WlanCloseHandle to close the connection when the program exits.
DWORD WINAPI WlanOpenHandle (_ In_ DWORD dwClientVersion, _ Reserved_ PVOID pReserved, _ Out_ PDWORD pdwNegotiatedVersion, _ Out_ PHANDLE phClientHandle); DWORD WINAPI WlanCloseHandle (_ In_ HANDLE hClientHandle, _ Reserved_ PVOID pReserved)
two。 The following functions are used to set some properties of the hosting 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) Typedef enum _ WLAN_HOSTED_NETWORK_OPCODE {wlan_hosted_network_opcode_connection_settings, / / set some connection properties wlan_hosted_network_opcode_security_settings, / / set security properties wlan_hosted_network_opcode_station_profile / / query the wireless Hosted Network station profile wlan_hosted_network_opcode_enable / / query or set the wireless Hosted Network enabled flag} WLAN_HOSTED_NETWORK_OPCODE, * PWLAN_HOSTED_NETWORK_OPCODE
3. Enable and disable wireless bearer networks.
Open the Network and sharing Center and click to change the adapter settings. If the wireless hosted network panel is enabled, there will be a virtual network card described as Microsoft Virtual WiFi Miniport Adapter. After it is disabled, the virtual network card will disappear.
Of course, wifi can be shared only if the wireless bearer network is enabled.
DWORD WINAPI WlanHostedNetworkForceStart (_ In_ HANDLE hClientHandle, _ Out_opt_ PWLAN_HOSTED_NETWORK_REASON pFailReason, _ Reserved_ PVOID pvReserved); DWORD WINAPI WlanHostedNetworkForceStop (_ In_ HANDLE hClientHandle, _ Out_opt_ PWLAN_HOSTED_NETWORK_REASON pFailReason, _ Reserved_ PVOID pvReserved)
4. Connect and disconnect the network
DWORD WINAPI WlanHostedNetworkStartUsing (_ In_ HANDLE hClientHandle, _ Out_opt_ PWLAN_HOSTED_NETWORK_REASON pFailReason, _ Reserved_ PVOID pvReserved); DWORD WINAPI WlanHostedNetworkStopUsing (_ In_ HANDLE hClientHandle, _ Out_opt_ PWLAN_HOSTED_NETWORK_REASON pFailReason, _ Reserved_ PVOID pvReserved)
5. It is used to query the network status of the host network.
DWORD WINAPI WlanHostedNetworkQueryStatus (_ In_ HANDLE hClientHandle, _ Out_ PWLAN_HOSTED_NETWORK_STATUS * ppWlanHostedNetworkStatus, _ Reserved_ PVOID pvReserved); typedef struct _ WLAN_HOSTED_NETWORK_STATUS {WLAN_HOSTED_NETWORK_STATE HostedNetworkState; GUID IPDeviceID; DOT11_MAC_ADDRESS wlanHostedNetworkBSSID; DOT11_PHY_TYPE dot11PhyType; ULONG ulChannelFrequency DWORD dwNumberOfPeers; / / number of connected nodes WLAN_HOSTED_NETWORK_PEER_STATE PeerList [1]; / / Array of node information} WLAN_HOSTED_NETWORK_STATUS, * PWLAN_HOSTED_NETWORK_STATUS;typedef struct _ WLAN_HOSTED_NETWORK_PEER_STATE {DOT11_MAC_ADDRESS PeerMacAddress / / MAC address of node device WLAN_HOSTED_NETWORK_PEER_AUTH_STATE PeerAuthState; / / authentication status of node} WLAN_HOSTED_NETWORK_PEER_STATE, * PWLAN_HOSTED_NETWORK_PEER_STATE
Calling WlanHostedNetworkQueryStatus will get a WLAN_HOSTED_NETWORK_STATUS structure, so you can query some basic network information, such as the number of nodes connected to the network by dwNumberOfPeers. The PeerList array stores the details of the corresponding nodes, including MAC address and authentication status.
6. Used to set the password
Note that the password length must be greater than 8 and less than 63 or the call will fail.
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)
= = paste code = =
/ / WIFIMAIN.h implementation file # pragma once#include # pragma comment (lib, "wlanapi.lib") / / WIFIMAINclass WIFIMAIN: public CWnd {DECLARE_DYNAMIC (WIFIMAIN) public: WIFIMAIN (); virtual ~ WIFIMAIN (); protected: DECLARE_MESSAGE_MAP () private: bool allow; bool start; HANDLE hClient;public: int Init (void); int AllowHostedNetWork (void); int DisallowHostedNetWork (void) Int StartHostedNetWork (void); int StopHostedNetWork (void); bool isStart (void); bool isAllow (void); int Resume (void); int getpeernumber (void); int SetKEY (CString key); int SetSSID (CString ssidname);}
/ / WIFIMAIN.cpp: implement file / / # include "stdafx.h" # include "wifi share 1028.h" # include "WIFIMAIN.h" / / WIFIMAINIMPLEMENT_DYNAMIC (WIFIMAIN, CWnd) WIFIMAIN::WIFIMAIN (): allow (false), start (false) {Init ();} WIFIMAIN::~WIFIMAIN () {StopHostedNetWork (); WlanCloseHandle (hClient, NULL) } BEGIN_MESSAGE_MAP (WIFIMAIN, CWnd) END_MESSAGE_MAP () / / WIFIMAIN message handler int WIFIMAIN::Init (void) {DWORD dwCurVersion = 0; DWORD dwResult = 0; dwResult = WlanOpenHandle (WLAN_API_VERSION, NULL, & dwCurVersion, & hClient); if (ERROR_SUCCESS! = dwResult) {return-1;} BOOL bIsAllow = true; WLAN_HOSTED_NETWORK_REASON dwFailedReason DwResult = WlanHostedNetworkSetProperty (hClient, wlan_hosted_network_opcode_enable, sizeof (BOOL)) & bIsAllow, & dwFailedReason NULL) If (ERROR_SUCCESS! = dwResult) {return-2;} return 0;} int WIFIMAIN::AllowHostedNetWork (void) {PWLAN_HOSTED_NETWORK_REASON pFailReason = NULL; DWORD dwResult= 0; dwResult=WlanHostedNetworkForceStart (hClient,pFailReason,NULL); if (dwResult! = ERROR_SUCCESS) {return-1 } allow=true; return 0;} int WIFIMAIN::DisallowHostedNetWork (void) {PWLAN_HOSTED_NETWORK_REASON pFailReason = NULL; DWORD dwResult= 0; dwResult=WlanHostedNetworkForceStop (hClient,pFailReason,NULL); if (dwResult! = ERROR_SUCCESS) {return-1;} allow=false; return 0 } int WIFIMAIN::StartHostedNetWork (void) {PWLAN_HOSTED_NETWORK_REASON pFailReason = NULL; DWORD dwResult= 0; dwResult=WlanHostedNetworkStartUsing (hClient,pFailReason,NULL); if (dwResult! = ERROR_SUCCESS) {return-1;} start=true; return 0;} int WIFIMAIN::StopHostedNetWork (void) {PWLAN_HOSTED_NETWORK_REASON pFailReason = NULL; DWORD dwResult= 0 DwResult=WlanHostedNetworkStopUsing (hClient,pFailReason,NULL); if (dwResult! = ERROR_SUCCESS) {return-1;} start=false; return 0;} bool WIFIMAIN::isStart (void) {return start;} bool WIFIMAIN::isAllow (void) {return allow;} int WIFIMAIN::Resume (void) {DWORD dwResult= 0; BOOL bIsAllow = false WLAN_HOSTED_NETWORK_REASON dwFailedReason DwResult = WlanHostedNetworkSetProperty (hClient, wlan_hosted_network_opcode_enable, sizeof (BOOL)) & bIsAllow, & dwFailedReason NULL) If (ERROR_SUCCESS! = dwResult) {return-2;} return 0;} int WIFIMAIN::getpeernumber (void) {PWLAN_HOSTED_NETWORK_STATUS ppWlanHostedNetworkStatus=NULL; int retval = WlanHostedNetworkQueryStatus (hClient,&ppWlanHostedNetworkStatus,NULL); if (retval! = ERROR_SUCCESS) {return-1;} return ppWlanHostedNetworkStatus- > dwNumberOfPeers } int WIFIMAIN::SetKEY (CString key) {char chkey [64]; int index; for (index=0; index
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.