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

推荐订阅源

J
Java Code Geeks
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
H
Hackread – Cybersecurity News, Data Breaches, AI and More
腾讯CDC
F
Fortinet All Blogs
I
InfoQ
Jina AI
Jina AI
有赞技术团队
有赞技术团队
A
About on SuperTechFans
Stack Overflow Blog
Stack Overflow Blog
小众软件
小众软件
Recent Announcements
Recent Announcements
aimingoo的专栏
aimingoo的专栏
雷峰网
雷峰网
B
Blog RSS Feed
C
Check Point Blog
Y
Y Combinator Blog
博客园 - 聂微东
云风的 BLOG
云风的 BLOG
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Hugging Face - Blog
Hugging Face - Blog
Microsoft Security Blog
Microsoft Security Blog
Engineering at Meta
Engineering at Meta
G
Google Developers 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    }