How to detect Terminal Server in VB.NET

G

Guest

Hi,
I need code in VB.Net to detect if the application is running on Terminal
Server.
I am using the following code. Please let me know if you see any issues in
it or if you have some better code to achieve this functionality:

Dim sTemp As String = Environment.GetEnvironmentVariable("SESSIONNAME")
Dim IsTSSession As String
If (sTemp <> "") And (sTemp.IndexOf("RDP-") = 0) Then
IsTSSession = True
Else
IsTSSession = False
End If

Thanks,
Hitesh
 
M

Mattias Sjögren

I am using the following code. Please let me know if you see any issues in
it or if you have some better code to achieve this functionality:

In .NET 2.0 you can check
System.Windows.Forms.SystemInformation.TerminalServerSession. In
earlier versions you can call the GetSystemMetrics(SM_REMOTESESSION)
API.


Mattias
 
G

Guest

Thanks very much for replying..
But can you please let me know how to use GetSystemMetrics(SM_REMOTESESSION)
in Vb.Net code.
Also do you see any issues in the code that I am using?...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top