打印 上一主题 下一主题

[源码] 【虚拟WiFi】迷你虚拟wifi无线路由器Virtual Router Plus

[复制链接]
跳转到指定楼层
楼主
查看: 14867|回复: 22
迷你虚拟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);
    }
}




案例源码下载:

分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏4 转播转播
回复 论坛版权

使用道具 举报

沙发
iHomeSoft 发表于 2014-8-2 10:49:40 | 只看该作者
我也写过一个,用cmd命令实现的
板凳
iHomeSoft 发表于 2014-8-2 10:50:47 | 只看该作者
我写过一个用cmd做的
地板
原始 发表于 2014-8-2 10:57:11 | 只看该作者
这个不错,我要仔细看看
5#
 楼主| 乔克斯 发表于 2014-8-2 11:04:26 | 只看该作者
iHomeSoft 发表于 2014-8-2 10:50
我写过一个用cmd做的

>A<求发帖分享~康忙~
6#
shaohuatsou 发表于 2014-8-2 11:41:37 | 只看该作者
{:3_41:}
回复

使用道具 举报

7#
smalltalkhyb 发表于 2014-8-2 17:47:14 | 只看该作者
支持一下
回复

使用道具 举报

8#
CSC 发表于 2014-8-4 09:30:00 | 只看该作者
支持支持
回复

使用道具 举报

9#
wine 发表于 2015-10-15 14:56:08 | 只看该作者
留下脚印,日后再来,谢谢分享!!!
10#
yy981420974 发表于 2015-10-22 08:09:03 来自手机 | 只看该作者
太厉害了,楼主真棒?
您需要登录后才可以回帖 登录 | 加入CSkin博客

本版积分规则

QQ|申请友链|小黑屋|手机版|Archiver|CSkin ( 粤ICP备13070794号

Powered by Discuz! X3.2  © 2001-2013 Comsenz Inc.  Designed by ARTERY.cn
GMT+8, 2024-11-16 10:31, Processed in 0.581580 second(s), 38 queries , Gzip On.

快速回复 返回顶部 返回列表