How to test if RemoteDesktop still connected from c# Options

  • Thread starter Thread starter lawrence.barwick@googlemail.com
  • Start date Start date
L

lawrence.barwick@googlemail.com

Guest
I am trying to write an app in c# that monitors open RDCs and warns
me
if a connection goes down. I tried looking for ip address in
TaskManager list - which works, it can see difference between a RCD
window that has been logged into and one that has been cancelled (by
user). However, if connection is lost due to internet - I am not able
to look for anything that tells me this.

If anyone can think of a way that I can test whether a connection if
still up an running - I would be greateful. Obviously, I can tell on
the host side, but I want this to be from the side that initiated the
RDC.


Many thanks,


Lawrence
 
Re: How to test if RemoteDesktop still connected from c# Options

Hi Lawrence,

You can wrap the Remote Desktop activex and then respond
to the various events as needed. Instead of connecting using
the regular RD client you would use your program to connect
instead.

-TP

lawrence.barwick@googlemail.com wrote:
> I am trying to write an app in c# that monitors open RDCs and warns
> me
> if a connection goes down. I tried looking for ip address in
> TaskManager list - which works, it can see difference between a RCD
> window that has been logged into and one that has been cancelled (by
> user). However, if connection is lost due to internet - I am not able
> to look for anything that tells me this.
>
> If anyone can think of a way that I can test whether a connection if
> still up an running - I would be greateful. Obviously, I can tell on
> the host side, but I want this to be from the side that initiated the
> RDC.
>
>
> Many thanks,
>
>
> Lawrence
 
Re: How to test if RemoteDesktop still connected from c# Options

On 27 Jul, 19:53, "TP" <tperson.knowsp...@mailandnews.com> wrote:
> Hi Lawrence,
>
> You can wrap the Remote Desktop activex and then respond
> to the various events as needed. Instead of connecting using
> the regular RD client you would use your program to connect
> instead.
>
> -TP
>
>
>
> lawrence.barw...@googlemail.com wrote:
> > I am trying to write an app in c# that monitors open RDCs and warns
> > me
> > if a connection goes down. I tried looking for ip address in
> > TaskManager list - which works, it can see difference between a RCD
> > window that has been logged into and one that has been cancelled (by
> > user). However, if connection is lost due to internet - I am not able
> > to look for anything that tells me this.

>
> > If anyone can think of a way that I can test whether a connection if
> > still up an running - I would be greateful. Obviously, I can tell on
> > the host side, but I want this to be from the side that initiated the
> > RDC.

>
> > Many thanks,

>
> > Lawrence- Hide quoted text -

>
> - Show quoted text -


TP,

Could you give me, or point me to a link that demonstrates what you
mean by 'wrap' please.

Thanks for responding,

Lawrence
 
Re: How to test if RemoteDesktop still connected from c# Options

Hi Lawrence,

You need to add the Microsoft RDP Client Control to a
form--it is a COM Component. Then you can set its
properties, call its methods, and respond to its events.

For example, after you have the control on the form,
you could put a button with code to perform the
connection:

private void button1_Click(object sender, EventArgs e)
{
axMsRdpClient31.Server = "servername";
axMsRdpClient31.Connect();
}

You will also want to respond to the various events as
your needs dictate such as OnDisconnected.

Documentation of the methods, properties, and events are
up on MSDN.

-TP

lawrence.barwick@googlemail.com wrote:
> TP,
>
> Could you give me, or point me to a link that demonstrates what you
> mean by 'wrap' please.
>
> Thanks for responding,
>
> Lawrence
 
Re: How to test if RemoteDesktop still connected from c# Options

On 30 Jul, 14:28, "TP" <tperson.knowsp...@mailandnews.com> wrote:
> Hi Lawrence,
>
> You need to add the Microsoft RDP Client Control to a
> form--it is a COM Component. Then you can set its
> properties, call its methods, and respond to its events.
>
> For example, after you have the control on the form,
> you could put a button with code to perform the
> connection:
>
> private void button1_Click(object sender, EventArgs e)
> {
> axMsRdpClient31.Server = "servername";
> axMsRdpClient31.Connect();
>
> }
>
> You will also want to respond to the various events as
> your needs dictate such as OnDisconnected.
>
> Documentation of the methods, properties, and events are
> up on MSDN.
>
> -TP
>
>
>
> lawrence.barw...@googlemail.com wrote:
> > TP,

>
> > Could you give me, or point me to a link that demonstrates what you
> > mean by 'wrap' please.

>
> > Thanks for responding,

>
> > Lawrence- Hide quoted text -

>
> - Show quoted text -


TP,

I appreciate your help with this. I don't have that as a COM object
and I've really tried searching MSDN for anything ro do with
RemoteDesktop but I must be doing something wrong - as I find
nothing. Could you tell me the name of the Class? I tried
RemoteDesktop and RdpClient31 but it doesn't get me anywhere...

Thanks again,

Lawrence
 
Re: How to test if RemoteDesktop still connected from c# Options

In your list of COM Components, scroll down and look
for the following (entries will vary depending on which
TS client(s) you have installed):

Microsoft RDP Client Control
Microsoft RDP Client Control (redist)
Microsoft Terminal Services Control

The files to look for are mstscax.dll and msrdp.ocx

IMsRdpClient

http://msdn2.microsoft.com/en-us/library/Aa381344.aspx

-TP

lawrence.barwick@googlemail.com wrote:
> TP,
>
> I appreciate your help with this. I don't have that as a COM object
> and I've really tried searching MSDN for anything ro do with
> RemoteDesktop but I must be doing something wrong - as I find
> nothing. Could you tell me the name of the Class? I tried
> RemoteDesktop and RdpClient31 but it doesn't get me anywhere...
>
> Thanks again,
>
> Lawrence
 
Re: How to test if RemoteDesktop still connected from c# Options

On 30 Jul, 15:47, "TP" <tperson.knowsp...@mailandnews.com> wrote:
> In your list of COM Components, scroll down and look
> for the following (entries will vary depending on which
> TS client(s) you have installed):
>
> Microsoft RDP Client Control
> Microsoft RDP Client Control (redist)
> Microsoft Terminal Services Control
>
> The files to look for are mstscax.dll and msrdp.ocx
>
> IMsRdpClient
>
> http://msdn2.microsoft.com/en-us/library/Aa381344.aspx
>
> -TP
>
>
>
> lawrence.barw...@googlemail.com wrote:
> > TP,

>
> > I appreciate your help with this. I don't have that as a COM object
> > and I've really tried searching MSDN for anything ro do with
> > RemoteDesktop but I must be doing something wrong - as I find
> > nothing. Could you tell me the name of the Class? I tried
> > RemoteDesktop and RdpClient31 but it doesn't get me anywhere...

>
> > Thanks again,

>
> > Lawrence- Hide quoted text -

>
> - Show quoted text -


TP,

Thanks.

I found Microsoft Terminal Services Control refernce
and put in a Using MSTSClib line.

Is there a different between a MsRdpClient and an IMsRdpClient?

What I want is to programmatically open RemoteDesktop (as if it had
been done via GUI) so that users can view it, but be able to monitor
in c# to see if it gets disconnected. Do you think that it possible?

Lawrence
 
Re: How to test if RemoteDesktop still connected from c# Options

Lawrence,

Yes, it is possible. The sample code I gave you is the
minimum to establish a connection and interact with
a session on the server.

Now write code to respond to the events you are
interested in as well as add features to the form such as
the ability to specify server name, display options,
redirection options, etc.

In a couple of hours or so you should be able to
have a custom version that has all the features of the
regular Remote Desktop Client plus the ability to monitor
and respond to disconnects.

-TP

lawrence.barwick@googlemail.com wrote:
> TP,
>
> Thanks.
>
> I found Microsoft Terminal Services Control refernce
> and put in a Using MSTSClib line.
>
> Is there a different between a MsRdpClient and an IMsRdpClient?
>
> What I want is to programmatically open RemoteDesktop (as if it had
> been done via GUI) so that users can view it, but be able to monitor
> in c# to see if it gets disconnected. Do you think that it possible?
>
> Lawrence
 
Re: How to test if RemoteDesktop still connected from c# Options

On 30 Jul, 16:33, "TP" <tperson.knowsp...@mailandnews.com> wrote:
> Lawrence,
>
> Yes, it is possible. The sample code I gave you is the
> minimum to establish a connection and interact with
> a session on the server.
>
> Now write code to respond to the events you are
> interested in as well as add features to the form such as
> the ability to specify server name, display options,
> redirection options, etc.
>
> In a couple of hours or so you should be able to
> have a custom version that has all the features of the
> regular Remote Desktop Client plus the ability to monitor
> and respond to disconnects.
>
> -TP
>
>
>
> lawrence.barw...@googlemail.com wrote:
> > TP,

>
> > Thanks.

>
> > I found Microsoft Terminal Services Control refernce
> > and put in a Using MSTSClib line.

>
> > Is there a different between a MsRdpClient and an IMsRdpClient?

>
> > What I want is to programmatically open RemoteDesktop (as if it had
> > been done via GUI) so that users can view it, but be able to monitor
> > in c# to see if it gets disconnected. Do you think that it possible?

>
> > Lawrence- Hide quoted text -

>
> - Show quoted text -


TP,

You have been a great help!

I am able to run following code without errors, but, no RDP window
appears. I looked for a .visable property, but there does not seem to
be one. Is there something I am missing? Sorry, to ask again, but you
have been very accommodating...

Lawrence

IMsRdpClient RDP = new MsRdpClient();
RDP.Server = "156.4x.xx.xx";
RDP.UserName = "xxxx";
RDP.FullScreen = true;
RDP.DesktopHeight = 300;
RDP.DesktopWidth = 300;
RDP.Connect();
 
Re: How to test if RemoteDesktop still connected from c# Options

On 30 Jul, 16:40, lawrence.barw...@googlemail.com wrote:
> On 30 Jul, 16:33, "TP" <tperson.knowsp...@mailandnews.com> wrote:
>
>
>
>
>
> > Lawrence,

>
> > Yes, it is possible. The sample code I gave you is the
> > minimum to establish a connection and interact with
> > a session on the server.

>
> > Now write code to respond to the events you are
> > interested in as well as add features to the form such as
> > the ability to specify server name, display options,
> > redirection options, etc.

>
> > In a couple of hours or so you should be able to
> > have a custom version that has all the features of the
> > regular Remote Desktop Client plus the ability to monitor
> > and respond to disconnects.

>
> > -TP

>
> > lawrence.barw...@googlemail.com wrote:
> > > TP,

>
> > > Thanks.

>
> > > I found Microsoft Terminal Services Control refernce
> > > and put in a Using MSTSClib line.

>
> > > Is there a different between a MsRdpClient and an IMsRdpClient?

>
> > > What I want is to programmatically open RemoteDesktop (as if it had
> > > been done via GUI) so that users can view it, but be able to monitor
> > > in c# to see if it gets disconnected. Do you think that it possible?

>
> > > Lawrence- Hide quoted text -

>
> > - Show quoted text -

>
> TP,
>
> You have been a great help!
>
> I am able to run following code without errors, but, no RDP window
> appears. I looked for a .visable property, but there does not seem to
> be one. Is there something I am missing? Sorry, to ask again, but you
> have been very accommodating...
>
> Lawrence
>
> IMsRdpClient RDP = new MsRdpClient();
> RDP.Server = "156.4x.xx.xx";
> RDP.UserName = "xxxx";
> RDP.FullScreen = true;
> RDP.DesktopHeight = 300;
> RDP.DesktopWidth = 300;
> RDP.Connect();- Hide quoted text -
>
> - Show quoted text -




I assume I should see the normal RDP window when I call connect? or is
that not the case?

Lawrence
 
Re: How to test if RemoteDesktop still connected from c# Options

Lawrence,

Here are some steps to get you started:

1. Start a new c# windows project
2. Tools-->Choose Toolbox Items-->COM components tab,
check Microsoft RDP Client Control (or similar), click OK
3. Drag the RDP control from the toolbox and drop it on your form
4. Drag a button from the toolbox and drop it on your form
5. Type the code for the button's click event, use my sample
code from earlier as a guideline, making changes/additions
where necessary

Once you get the above working fine you can start adding
features to suit your tastes--perhaps you want one form for
all of the connection settings and a separate form to hold the RDP
control.

-TP

lawrence.barwick@googlemail.com wrote:
> TP,
>
> You have been a great help!
>
> I am able to run following code without errors, but, no RDP window
> appears. I looked for a .visable property, but there does not seem to
> be one. Is there something I am missing? Sorry, to ask again, but you
> have been very accommodating...
>
> Lawrence
>
> IMsRdpClient RDP = new MsRdpClient();
> RDP.Server = "156.4x.xx.xx";
> RDP.UserName = "xxxx";
> RDP.FullScreen = true;
> RDP.DesktopHeight = 300;
> RDP.DesktopWidth = 300;
> RDP.Connect();
 
Re: How to test if RemoteDesktop still connected from c# Options

On 30 Jul, 19:26, "TP" <tperson.knowsp...@mailandnews.com> wrote:
> Lawrence,
>
> Here are some steps to get you started:
>
> 1. Start a new c# windows project
> 2. Tools-->Choose Toolbox Items-->COM components tab,
> check Microsoft RDP Client Control (or similar), click OK
> 3. Drag the RDP control from the toolbox and drop it on your form
> 4. Drag a button from the toolbox and drop it on your form
> 5. Type the code for the button's click event, use my sample
> code from earlier as a guideline, making changes/additions
> where necessary
>
> Once you get the above working fine you can start adding
> features to suit your tastes--perhaps you want one form for
> all of the connection settings and a separate form to hold the RDP
> control.
>
> -TP
>
>
>
> lawrence.barw...@googlemail.com wrote:
> > TP,

>
> > You have been a great help!

>
> > I am able to run following code without errors, but, no RDP window
> > appears. I looked for a .visable property, but there does not seem to
> > be one. Is there something I am missing? Sorry, to ask again, but you
> > have been very accommodating...

>
> > Lawrence

>
> > IMsRdpClient RDP = new MsRdpClient();
> > RDP.Server = "156.4x.xx.xx";
> > RDP.UserName = "xxxx";
> > RDP.FullScreen = true;
> > RDP.DesktopHeight = 300;
> > RDP.DesktopWidth = 300;
> > RDP.Connect();- Hide quoted text -

>
> - Show quoted text -


TP,

Great - got that working.

Could you tell me how to put an ondisconnected handler in?

Do I create a method with that name?

I find there is no sample code on MSDN at all - otherwise I would not
continue to bother you.

Many thanks,

Lawrence
 
Re: How to test if RemoteDesktop still connected from c# Options

On 31 Jul, 09:23, lawrence.barw...@googlemail.com wrote:
> On 30 Jul, 19:26, "TP" <tperson.knowsp...@mailandnews.com> wrote:
>
>
>
>
>
> > Lawrence,

>
> > Here are some steps to get you started:

>
> > 1. Start a new c# windows project
> > 2. Tools-->Choose Toolbox Items-->COM components tab,
> > check Microsoft RDP Client Control (or similar), click OK
> > 3. Drag the RDP control from the toolbox and drop it on your form
> > 4. Drag a button from the toolbox and drop it on your form
> > 5. Type the code for the button's click event, use my sample
> > code from earlier as a guideline, making changes/additions
> > where necessary

>
> > Once you get the above working fine you can start adding
> > features to suit your tastes--perhaps you want one form for
> > all of the connection settings and a separate form to hold the RDP
> > control.

>
> > -TP

>
> > lawrence.barw...@googlemail.com wrote:
> > > TP,

>
> > > You have been a great help!

>
> > > I am able to run following code without errors, but, no RDP window
> > > appears. I looked for a .visable property, but there does not seem to
> > > be one. Is there something I am missing? Sorry, to ask again, but you
> > > have been very accommodating...

>
> > > Lawrence

>
> > > IMsRdpClient RDP = new MsRdpClient();
> > > RDP.Server = "156.4x.xx.xx";
> > > RDP.UserName = "xxxx";
> > > RDP.FullScreen = true;
> > > RDP.DesktopHeight = 300;
> > > RDP.DesktopWidth = 300;
> > > RDP.Connect();- Hide quoted text -

>
> > - Show quoted text -

>
> TP,
>
> Great - got that working.
>
> Could you tell me how to put an ondisconnected handler in?
>
> Do I create a method with that name?
>
> I find there is no sample code on MSDN at all - otherwise I would not
> continue to bother you.
>
> Many thanks,
>
> Lawrence- Hide quoted text -
>
> - Show quoted text -


Actually found some code at last!

Thanks TP got that all working now.

But I have another question please: How can I connect as 'console'
please. i.e. when I am connecting to Srver where more than one session
can be established?

normally I run 'mstsc /console' is there a way I could specify that?

Lawrence
 
Re: How to test if RemoteDesktop still connected from c# Options

On 31 Jul, 09:56, lawrence.barw...@googlemail.com wrote:
> On 31 Jul, 09:23, lawrence.barw...@googlemail.com wrote:
>
>
>
>
>
> > On 30 Jul, 19:26, "TP" <tperson.knowsp...@mailandnews.com> wrote:

>
> > > Lawrence,

>
> > > Here are some steps to get you started:

>
> > > 1. Start a new c# windows project
> > > 2. Tools-->Choose Toolbox Items-->COM components tab,
> > > check Microsoft RDP Client Control (or similar), click OK
> > > 3. Drag the RDP control from the toolbox and drop it on your form
> > > 4. Drag a button from the toolbox and drop it on your form
> > > 5. Type the code for the button's click event, use my sample
> > > code from earlier as a guideline, making changes/additions
> > > where necessary

>
> > > Once you get the above working fine you can start adding
> > > features to suit your tastes--perhaps you want one form for
> > > all of the connection settings and a separate form to hold the RDP
> > > control.

>
> > > -TP

>
> > > lawrence.barw...@googlemail.com wrote:
> > > > TP,

>
> > > > You have been a great help!

>
> > > > I am able to run following code without errors, but, no RDP window
> > > > appears. I looked for a .visable property, but there does not seem to
> > > > be one. Is there something I am missing? Sorry, to ask again, but you
> > > > have been very accommodating...

>
> > > > Lawrence

>
> > > > IMsRdpClient RDP = new MsRdpClient();
> > > > RDP.Server = "156.4x.xx.xx";
> > > > RDP.UserName = "xxxx";
> > > > RDP.FullScreen = true;
> > > > RDP.DesktopHeight = 300;
> > > > RDP.DesktopWidth = 300;
> > > > RDP.Connect();- Hide quoted text -

>
> > > - Show quoted text -

>
> > TP,

>
> > Great - got that working.

>
> > Could you tell me how to put an ondisconnected handler in?

>
> > Do I create a method with that name?

>
> > I find there is no sample code on MSDN at all - otherwise I would not
> > continue to bother you.

>
> > Many thanks,

>
> > Lawrence- Hide quoted text -

>
> > - Show quoted text -

>
> Actually found some code at last!
>
> Thanks TP got that all working now.
>
> But I have another question please: How can I connect as 'console'
> please. i.e. when I am connecting to Srver where more than one session
> can be established?
>
> normally I run 'mstsc /console' is there a way I could specify that?
>
> Lawrence- Hide quoted text -
>
> - Show quoted text -


TP,

I worked that out too. Making some progress here!

I have an issue I can't resolve - when I connect I go to fullscreen
mode then if I minmize window it collapses to taskbar, but I can't
maximise it again - all options are greyed out except 'close'...

Lawrence
 
Adding "Microsoft RDP Client Control" to Toolbox in C#Windows service project

Adding "Microsoft RDP Client Control" to Toolbox in C#Windows service project

TP (or anyone),

I am wading through COM for the first time. One of my first tasks is to get a Windows service (a C# project in VS 2008) instantiate an IMsRdpClient object and make a TS connection.

I found this post that was helpful, however when going through the list of steps repeated here:

Here are some steps to get you started:

1. Start a new c# windows project
2. Tools-->Choose Toolbox Items-->COM components tab,
check Microsoft RDP Client Control (or similar), click OK
3. Drag the RDP control from the toolbox and drop it on your form
4. Drag a button from the toolbox and drop it on your form
5. Type the code for the button's click event, use my sample
code from earlier as a guideline, making changes/additions
where necessary


I became stuck on number 3. On a Windows Form App project (I did this in parallel), the "Microsoft RDP Client Control" does appear under "All Windows Forms" in the toolbox. However, it does not appear in the Windows service project.

Any explanation of why would be appreciated. Any solutions, even more so!

Thanks to all for reading
KK
 
Re: Adding "Microsoft RDP Client Control" to Toolbox in C# Windows service project

Re: Adding "Microsoft RDP Client Control" to Toolbox in C# Windows service project

Hi,

I think you have to use a tool to import the ocx that will generate
AxMSTSCLib.dll for you, then

you can use the OCX in .NET project. I suggest you to download Royal TS and
learn from it,

it's an open source program that wraps the MSRDP.OCX, very nice. Search on
internet you will find some more

Regards

ThomasT.

<KK> wrote in message news:200866122830ksquared.software@gmail.com...
> TP (or anyone),
>
> I am wading through COM for the first time. One of my first tasks is to
> get a Windows service (a C# project in VS 2008) instantiate an
> IMsRdpClient object and make a TS connection.
>
> I found this post that was helpful, however when going through the list of
> steps repeated here:
>
> Here are some steps to get you started:
>
> 1. Start a new c# windows project
> 2. Tools-->Choose Toolbox Items-->COM components tab,
> check Microsoft RDP Client Control (or similar), click OK
> 3. Drag the RDP control from the toolbox and drop it on your form
> 4. Drag a button from the toolbox and drop it on your form
> 5. Type the code for the button's click event, use my sample
> code from earlier as a guideline, making changes/additions
> where necessary
>
>
> I became stuck on number 3. On a Windows Form App project (I did this in
> parallel), the "Microsoft RDP Client Control" does appear under "All
> Windows Forms" in the toolbox. However, it does not appear in the Windows
> service project.
>
> Any explanation of why would be appreciated. Any solutions, even more so!
>
> Thanks to all for reading
> KK
 
Back
Top