CSkin博客

标题: 【虚拟WiFi】迷你虚拟wifi无线路由器Virtual Router Plus [打印本页]

作者: 乔克斯    时间: 2014-8-2 01:48
标题: 【虚拟WiFi】迷你虚拟wifi无线路由器Virtual Router Plus
迷你虚拟wifi无线路由器Virtual Router Plus
效果截图:


一、源码介绍
    亲,还在为自己的手机流量不够用而烦恼吗,有了这一款非常实用的WiFi共享的的网络工具源码,
    使用的时候只需要添加无线名称、密码,选择要共享的网络就可以通过本机的无线网卡虚拟一个无线路由器。
    然后用手机打开WiFi,然后输入密码就可以轻松用手机上网,本人亲测可用,感兴趣的朋友们赶紧来下载哦。
二、功能介绍
    该源码主要实现了用笔记本或者有无线接收器的台式电脑搭建成一个无线路由器实现手机上网的功能。
一个小巧灵活的wifi共享工具源码,只需要添加无线名称、密码,选择要共享的网络,就可以通过本机的无线网卡虚拟一个无线路由器。
通过了大量的WindowsApi来实现对虚拟网卡的操作,核心代码在这里,当然这个只是提前给你看一下基本原理,必须下载下方的源码才能运行哦~,当然,首先,你得有个真正的无线网卡。
三、注意事项   
    1、使用的时候注意自己设置密码的时候最少要8位以上。
    2、该源码可以作为学习交流,或者二次开发使用。
    3、该源码的运行环境为vs2010,无数据库。   
运行环境:vs2010+无数据库


部分源码:
[C#] 纯文本查看 复制代码
using System;
using System.Runtime.InteropServices;

namespace VirtualRouterPlus
{
    public static class wlanapi
    {
        public const uint WLAN_CLIENT_VERSION_XP = 1;
        public const uint WLAN_CLIENT_VERSION_VISTA = 2;

        public const uint WLAN_AVAILABLE_NETWORK_INCLUDE_ALL_ADHOC_PROFILES = 0x00000001;
        public const uint WLAN_AVAILABLE_NETWORK_INCLUDE_ALL_MANUAL_HIDDEN_PROFILES = 0x00000002;

        public const uint WLAN_CONNECTION_HIDDEN_NETWORK = 0x00000001;
        public const uint WLAN_CONNECTION_ADHOC_JOIN_ONLY = 0x00000002;
        public const uint WLAN_CONNECTION_IGNORE_PRIVACY_BIT = 0x00000004;
        public const uint WLAN_CONNECTION_EAPOL_PASSTHROUGH = 0x00000008;


        [DllImport("Wlanapi.dll", SetLastError = true)]
        public static extern uint WlanConnect(IntPtr hClientHandle, ref Guid pInterfaceGuid, ref

WLAN_CONNECTION_PARAMETERS pConnectionParameters, IntPtr pReserved);

        /// <summary>
        ///
        /// </summary>
        /// <param name="hClientHandle"></param>
        /// <param name="pReserved">Must pass in IntPtr.Zero</param>
        /// <returns></returns>
        [DllImport("Wlanapi", EntryPoint = "WlanCloseHandle")]
        public static extern uint WlanCloseHandle([In] IntPtr hClientHandle, IntPtr pReserved);


        [DllImport("Wlanapi.dll", SetLastError = true, CharSet = CharSet.Unicode)]
        public static extern uint WlanDeleteProfile(IntPtr hClientHandle, ref Guid pInterfaceGuid, string

strProfileName, IntPtr pReserved);

        [DllImport("Wlanapi.dll", SetLastError = true)]
        public static extern uint WlanDisconnect(IntPtr hClientHandle, ref Guid pInterfaceGuid, IntPtr

pReserved);

        /// <summary>
        ///
        /// </summary>
        /// <param name="hClientHandle"></param>
        /// <param name="pReserved"></param>
        /// <param name="ppInterfaceList">Must pass in IntPtr.Zero</param>
        /// <returns></returns>
        [DllImport("Wlanapi", EntryPoint = "WlanEnumInterfaces")]
        public static extern uint WlanEnumInterfaces([In] IntPtr hClientHandle, IntPtr pReserved, ref IntPtr

ppInterfaceList);

        [DllImport("Wlanapi", EntryPoint = "WlanFreeMemory")]
        public static extern void WlanFreeMemory([In] IntPtr pMemory);

        [DllImport("Wlanapi.dll", SetLastError = true)]
        public static extern uint WlanGetAvailableNetworkList(IntPtr hClientHandle, ref Guid pInterfaceGuid,

uint dwFlags, IntPtr pReserved, ref IntPtr ppAvailableNetworkList);

        [DllImport("Wlanapi.dll", SetLastError = true, CharSet = CharSet.Unicode)]
        public static extern uint WlanGetProfile(IntPtr hClientHandle, ref Guid pInterfaceGuid, string

strProfileName, IntPtr pReserved, ref string pstrProfileXml, ref uint pdwFlags, ref uint pdwGrantedAccess);

        [DllImport("Wlanapi.dll", SetLastError = true)]
        public static extern uint WlanGetProfileList(IntPtr hClientHandle, ref Guid pInterfaceGuid, IntPtr

pReserved, ref IntPtr ppProfileList);



        [DllImport("Wlanapi.dll", EntryPoint = "WlanHostedNetworkForceStart")]
        public static extern uint WlanHostedNetworkForceStart(IntPtr hClientHandle, [Out] out

WLAN_HOSTED_NETWORK_REASON pFailReason, IntPtr pReserved);

        [DllImport("Wlanapi.dll", EntryPoint = "WlanHostedNetworkForceStop")]
        public static extern uint WlanHostedNetworkForceStop(IntPtr hClientHandle, [Out] out

WLAN_HOSTED_NETWORK_REASON pFailReason, IntPtr pReserved);

        [DllImport("Wlanapi.dll", EntryPoint = "WlanHostedNetworkInitSettings")]
        public static extern uint WlanHostedNetworkInitSettings(IntPtr hClientHandle, [Out] out

WLAN_HOSTED_NETWORK_REASON pFailReason, IntPtr pReserved);

        [DllImport("Wlanapi.dll", EntryPoint = "WlanHostedNetworkQueryProperty")]
        public static extern uint WlanHostedNetworkQueryProperty(IntPtr hClientHandle,

WLAN_HOSTED_NETWORK_OPCODE OpCode, [Out] out uint pDataSize,
            [Out] out IntPtr ppvData, [Out] out WLAN_OPCODE_VALUE_TYPE pWlanOpcodeValueType, IntPtr

pReserved);

        [DllImport("Wlanapi.dll", EntryPoint = "WlanHostedNetworkQuerySecondaryKey")]
        public static extern uint WlanHostedNetworkQuerySecondaryKey(IntPtr hClientHandle, [Out] out uint

pKeyLength,
            [Out, MarshalAs(UnmanagedType.LPStr)] out string ppucKeyData,
            [Out] out bool pbIsPassPhrase, [Out] out bool pbPersistent, [Out] out WLAN_HOSTED_NETWORK_REASON

pFailReason, IntPtr pReserved);

        [DllImport("Wlanapi.dll", EntryPoint = "WlanHostedNetworkQueryStatus")]
        public static extern uint WlanHostedNetworkQueryStatus(IntPtr hClientHandle,
            out IntPtr pWlanHostedNetworkStatus, IntPtr pReserved);

        [DllImport("Wlanapi.dll", EntryPoint = "WlanHostedNetworkRefreshSecuritySettings")]
        public static extern uint WlanHostedNetworkRefreshSecuritySettings(IntPtr hClientHandle, [Out] out

WLAN_HOSTED_NETWORK_REASON pFailReason, IntPtr pReserved);

        [DllImport("Wlanapi.dll", EntryPoint = "WlanHostedNetworkSetProperty")]
        public static extern uint WlanHostedNetworkSetProperty(IntPtr hClientHandle,

WLAN_HOSTED_NETWORK_OPCODE OpCode,
            uint dwDataSize, IntPtr pvData, [Out] out WLAN_HOSTED_NETWORK_REASON pFailReason, IntPtr

pReserved);

        [DllImport("Wlanapi.dll", EntryPoint = "WlanHostedNetworkSetSecondaryKey")]
        public static extern uint WlanHostedNetworkSetSecondaryKey(IntPtr hClientHandle, uint dwKeyLength,
            [In, MarshalAs(UnmanagedType.LPStr)] string pucKeyData,
            bool bIsPassPhrase, bool bPersistent, [Out] out WLAN_HOSTED_NETWORK_REASON pFailReason, IntPtr

pReserved);

        [DllImport("Wlanapi.dll", EntryPoint = "WlanHostedNetworkStartUsing")]
        public static extern uint WlanHostedNetworkStartUsing(IntPtr hClientHandle, [Out] out

WLAN_HOSTED_NETWORK_REASON pFailReason, IntPtr pReserved);

        [DllImport("Wlanapi.dll", EntryPoint = "WlanHostedNetworkStopUsing")]
        public static extern uint WlanHostedNetworkStopUsing(IntPtr hClientHandle, [Out] out

WLAN_HOSTED_NETWORK_REASON pFailReason, IntPtr pReserved);




        [DllImport("Wlanapi", EntryPoint = "WlanOpenHandle")]
        public static extern uint WlanOpenHandle(uint dwClientVersion, IntPtr pReserved, [Out] out uint

pdwNegotiatedVersion, ref IntPtr ClientHandle);

        [DllImport("Wlanapi", EntryPoint = "WlanQueryInterface")]
        public static extern uint WlanQueryInterface([In] IntPtr hClientHandle, [In] ref Guid pInterfaceGuid,

WLAN_INTF_OPCODE OpCode, IntPtr pReserved, [Out] out uint pdwDataSize, ref IntPtr ppData, IntPtr

pWlanOpcodeValueType);

        [DllImport("Wlanapi.dll", SetLastError = true, CharSet = CharSet.Unicode)]
        public static extern uint WlanReasonCodeToString(uint dwReasonCode, uint dwBufferSize, string

pStringBuffer, IntPtr pReserved);


        public delegate void WLAN_NOTIFICATION_CALLBACK(ref WLAN_NOTIFICATION_DATA notificationData, IntPtr

context);

        [DllImport("Wlanapi.dll", EntryPoint = "WlanRegisterNotification")]
        public static extern uint WlanRegisterNotification(IntPtr hClientHandle, WLAN_NOTIFICATION_SOURCE

dwNotifSource, bool bIgnoreDuplicate,
            WLAN_NOTIFICATION_CALLBACK funcCallback, IntPtr pCallbackContext, IntPtr pReserved, [Out] out

WLAN_NOTIFICATION_SOURCE pdwPrevNotifSource);


        [DllImport("Wlanapi.dll", SetLastError = true)]
        public static extern uint WlanScan(IntPtr hClientHandle, ref Guid pInterfaceGuid, IntPtr pDot11Ssid,

IntPtr pIeData, IntPtr pReserved);

        [DllImport("Wlanapi.dll")]
        public static extern uint WlanSetInterface(IntPtr hClientHandle, ref Guid pInterfaceGuid,

WLAN_INTF_OPCODE OpCode, uint dwDataSize, ref object obj, IntPtr pReserved);

        [DllImport("Wlanapi.dll", SetLastError = true, CharSet = CharSet.Unicode)]
        public static extern uint WlanSetProfile(IntPtr hClientHandle, ref Guid pInterfaceGuid, uint dwFlags,

string strProfileXml, string strAllUserProfileSecurity, bool bOverwrite, IntPtr pReserved, ref uint

pdwReasonCode);

        [DllImport("Wlanapi.dll", SetLastError = true, CharSet = CharSet.Unicode)]
        public static extern uint WlanSetProfileList(IntPtr hClientHandle, ref Guid pInterfaceGuid, uint

dwItems, string[] strProfileNames, IntPtr pReserved);

        [DllImport("Wlanapi.dll", SetLastError = true, CharSet = CharSet.Unicode)]
        public static extern uint WlanSetProfilePosition(IntPtr hClientHandle, ref Guid pInterfaceGuid, string

strProfileName, uint dwPosition, IntPtr pReserved);
    }
}




案例源码下载: 《XMWiFi共享工具源码》.rar (274.28 KB, 下载次数: 262, 售价: 1 金钱)


作者: iHomeSoft    时间: 2014-8-2 10:49
我也写过一个,用cmd命令实现的
作者: iHomeSoft    时间: 2014-8-2 10:50
我写过一个用cmd做的
作者: 原始    时间: 2014-8-2 10:57
这个不错,我要仔细看看
作者: 乔克斯    时间: 2014-8-2 11:04
iHomeSoft 发表于 2014-8-2 10:50
我写过一个用cmd做的

>A<求发帖分享~康忙~
作者: shaohuatsou    时间: 2014-8-2 11:41

作者: smalltalkhyb    时间: 2014-8-2 17:47
支持一下
作者: CSC    时间: 2014-8-4 09:30
支持支持
作者: wine    时间: 2015-10-15 14:56
留下脚印,日后再来,谢谢分享!!!
作者: yy981420974    时间: 2015-10-22 08:09
太厉害了,楼主真棒?
作者: hambor    时间: 2015-10-26 22:33
好!好!好!!
作者: whlanying    时间: 2015-10-27 15:26
楼主造诣很深啊,很多工具都不错。
作者: pilixiawa    时间: 2015-11-28 14:22
谢谢楼主分享,研究下。
作者: pilixiawa    时间: 2015-11-28 14:24
楼主很腻害呀!
作者: letandgo    时间: 2015-12-8 22:25
学习,好东东
作者: 愤怒的萝卜    时间: 2015-12-9 08:55
支持一下
作者: 饿猫    时间: 2015-12-26 11:15
太牛了,下载学习学习
作者: 饿猫    时间: 2015-12-26 11:15
太牛了,下载学习学习
作者: yy2010    时间: 2015-12-26 12:38
学习一下学习一下学习一下
作者: goucey    时间: 2016-4-14 23:24
好流弊,额 字数太少.
作者: windy    时间: 2016-7-8 16:38
跟360wifi一个原理吧
作者: Dr.IndigoC    时间: 2016-11-5 04:19
感谢楼主分享,一直在想校园网如何检测到wifi共享的。
作者: zhaoxg    时间: 2019-10-20 11:49
#在这里快速回复#这个不错,我要仔细看看




欢迎光临 CSkin博客 (http://bbs.cskin.net/) Powered by Discuz! X3.2