惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

V
V2EX
酷 壳 – CoolShell
酷 壳 – CoolShell
美团技术团队
有赞技术团队
有赞技术团队
Hugging Face - Blog
Hugging Face - Blog
罗磊的独立博客
S
SegmentFault 最新的问题
D
Docker
博客园 - 司徒正美
雷峰网
雷峰网
V
Visual Studio Blog
云风的 BLOG
云风的 BLOG
G
Google Developers Blog
The GitHub Blog
The GitHub Blog
A
About on SuperTechFans
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
博客园 - Franky
月光博客
月光博客
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
H
Hackread – Cybersecurity News, Data Breaches, AI and More
T
The Blog of Author Tim Ferriss
Google DeepMind News
Google DeepMind News
MyScale Blog
MyScale Blog
MongoDB | Blog
MongoDB | Blog

博客园 - 老D

.NET Memcached Client 扩展获取所有缓存Key SQL Server 2005 中新CTE语法 递归性能测试 合并 GridView 的单元格 在Crystal Report中将数字转为英文 在代码中恢复sql server 数据库 - 老D 获取同一网段内的SQL SERVER实例 C#动态加载DLL Asp.net 文件下载 在网页处理按键事件 - 老D - 博客园 SQL语句导入导出大全 跨应用程序进行 Forms 身份验证 GridView导出Excel ASP.NET数据库连接字符串的加密与解密 ASP.NET中GridView动态绑定数据实现编辑更新 ASp.NET 2.0中Page事件的执行顺序 批量insert数据 简繁转换 ASP.NET应用程序开发 经典算法-C#四种排序算法
连接远程服务器共享
老D · 2007-08-25 · via 博客园 - 老D

  1    public class NetWork
  2    {
  3        [StructLayout(LayoutKind.Sequential)]
  4        public class NetResource
  5        {
  6            Create net use sturcture
 69
 70            public RESOURCE_SCOPE dwScope;
 71            public RESOURCE_TYPE dwType;
 72            public RESOURCE_DISPLAYTYPE dwDisplayType;
 73            public RESOURCE_USAGE dwUsage;
 74            public string LocalName;
 75            public string RemoteName;
 76            public string Comment;
 77            public string Provider;
 78        }

 79
 80        ///   
 81        /// mpr.dll  
 82        ///   

 83        [DllImport("mpr.dll", CharSet = CharSet.Ansi)]
 84        public static extern int WNetAddConnection2A(NetResource netResource,
 85                                                     String password,
 86                                                     String Username,
 87                                                     int Flag);
 88
 89
 90        ///   
 91        /// Create net use.  
 92        ///   

 93        public int CreateNetConnection(string RemoteName, string Password, string UserName)
 94        {
 95            NetResource myNetResource = new NetResource();
 96            myNetResource.dwScope = NetResource.RESOURCE_SCOPE.RESOURCE_GLOBALNET;
 97            myNetResource.dwType = NetResource.RESOURCE_TYPE.RESOURCETYPE_ANY;
 98            myNetResource.dwDisplayType = NetResource.RESOURCE_DISPLAYTYPE.RESOURCEDISPLAYTYPE_GENERIC;
 99            myNetResource.dwUsage = NetResource.RESOURCE_USAGE.RESOURCEUSAGE_CONNECTABLE;
100            //myNetResource.LocalName = "Z:"; // Mapping to local dirver  
101            myNetResource.RemoteName = RemoteName; // Remote host IP or host name.  
102            myNetResource.Provider = null;
103            return WNetAddConnection2A(myNetResource, Password, UserName, 0);
104        }

105
106    }