如何在Asp.net2.0中调用msrdp(C#)
在本论坛查过了,没有找到解决办法。具体要实现的效果是打开一个页面就直接进入终端,想把msrdp写在一个类里面,各位大虾能帮我想想办法吗?
我只知道用VBscript可以这么写:
————————————————————————
<object id="MsRdpClient"
classid="CLSID:7584c670-2274-4efb-b00b-d6aaba6d3850"
codebase="/bin/msrdp.cab#version=5,2,3790,0"
>
</object>
<script language="vbscript" type="text/vbscript">
MsRdpClient.server = "elearning.starwit.net"
MsRdpClient.DesktopWidth = "800"
MsRdpClient.DesktopHeight = "600"
MsRdpClient.Width = "800"
MsRdpClient.Height = "600"
MsRdpClient.AdvancedSettings2.RedirectDrives = FALSE
MsRdpClient.AdvancedSettings2.RedirectPrinters = FALSE
MsRdpClient.AdvancedSettings2.RedirectPorts = FALSE
MsRdpClient.AdvancedSettings2.RedirectSmartCards = FALSE
MsRdpClient.UserName = "administrator"
MsRdpClient.Domain = ""
MsRdpClient.AdvancedSettings.ClearTextPassword = "acmelee330828"
MsRdpClient.Connect
</script>
————————————————————————
如果要写到类里面,前面有个帖子讨论到一半没有结果了,他的实现方法应该是这样的
需要先添加一个引用:c:\windows\system32\mstscax.dll
————————————————————————
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using MSTSCLib;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
int resWidth, resHeight;
MSTSCLib.MsRdpClient IMsTscAx = new MSTSCLib.MsRdpClient();
IMsTscAx.Server = "LocalHost";
IMsTscAx.UserName = "administrator";
IMsTscAx.FullScreen = false;
resWidth = 600;
resHeight = 800;
IMsTscAx.DesktopHeight = resHeight;
IMsTscAx.DesktopWidth = resWidth;
IMsTscAx.Connect();
}
}
————————————————————————
我在VS2006下做的,测试倒是什么错都没有报,只是页面什么都不显示。
先谢谢帮忙解答的人啦。 --------------------编程问答-------------------- 看来很晚了,高手都睡觉去了。 --------------------编程问答-------------------- 呵呵,就一个小人无 还在看, 我也是困呀,兄弟,只有先帮顶下, --------------------编程问答-------------------- 谢谢啊,我一直在这里等着呢? --------------------编程问答-------------------- activex控件在后台运行是没有界面的
--------------------编程问答-------------------- 谢谢幕白兄得回复。
那有没有办法把后台运行得控件转回前台呢?
我看到有人这么用
------------------------------------
private AxMSTSCLib.AxMsTscAx axMsTscAx1;
this.axMsTscAx1 = new AxMSTSCLib.AxMsTscAx();
((System.ComponentModel.ISupportInitialize)(this.axMsTscAx1)).BeginInit();
//
// axMsTscAx1
//
this.axMsTscAx1.Enabled = true;
this.axMsTscAx1.Location = new System.Drawing.Point(58, 17);
this.axMsTscAx1.Name = "axMsTscAx1"
this.axMsTscAx1.OcxState =
((System.Windows.Forms.AxHost.State)(resources.GetObject("axMsTscAx1.OcxStat
e")));
this.axMsTscAx1.Size = new System.Drawing.Size(192, 192);
this.axMsTscAx1.TabIndex = 1;
....
this.Controls.Add(this.axMsTscAx1);
((System.ComponentModel.ISupportInitialize)(this.axMsTscAx1)).EndInit();
------------------------------------
这个可以吗?我不知道该怎么继续了。 --------------------编程问答-------------------- --------------------编程问答-------------------- 我正在研究这方面的东西,可以一起研究下!
补充:.NET技术 , ASP.NET