C#网络登录 [英] c# network login

查看:136
本文介绍了C#网络登录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何进行网络登录,访问共享驱动器,例如,C#编程?同样可以通过尝试通过资源管理器打开一个共享或通过net use shell命令。

How do I perform a network login, to access a shared driver for instance, programmatically in c#? The same can be achieved by either attempting to open a share through the explorer, or by the net use shell command.

推荐答案

实现P / Invoke调用到 WNetAddConnection2 会做的伎俩。看更多信息href=\"http://cticoder.wordpress.com/2008/08/11/msbuild-custom-task-drive-mapper/\">。

P/Invoke call to WNetAddConnection2 will do the trick. Look here for more info.

[DllImport("mpr.dll")]
 public static extern int WNetAddConnection2A
 (
      [MarshalAs(UnmanagedType.LPArray)] NETRESOURCEA[] lpNetResource,
      [MarshalAs(UnmanagedType.LPStr)] string lpPassword,
      [MarshalAs(UnmanagedType.LPStr)] string UserName, int dwFlags
 );

这篇关于C#网络登录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆