Atlanta Custom Software Development 

 
   Search        Code/Page
 

User Login
Email

Password

 

Forgot the Password?
Services
» Web Development
» Maintenance
» Data Integration/BI
» Information Management
Programming
  Database
Automation
OS/Networking
Graphics
Links
Tools
» Regular Expr Tester
» Free Tools


I most of time use terminal client to connect my server and run most of my stuff like that. You might be have the same situation. This simple code will tell you whether you are running in terminal server or not.

Step-By-Step Example

- Create a standard exe and copy/paste the following code in form1
- Try to run the same code inside terminal client and see the

Click here to copy the following block
Option Explicit

Private Const VER_SERVER_NT As Long = &H80000000
Private Const VER_WORKSTATION_NT As Long = &H40000000
Private Const VER_SUITE_SMALLBUSINESS As Long = &H1
Private Const VER_SUITE_ENTERPRISE As Long = &H2
Private Const VER_SUITE_BACKOFFICE As Long = &H4
Private Const VER_SUITE_COMMUNICATIONS As Long = &H8
Private Const VER_SUITE_TERMINAL As Long = &H10
Private Const VER_SUITE_SMALLBUSINESS_RESTRICTED As Long = &H20
Private Const VER_SUITE_EMBEDDEDNT As Long = &H40
Private Const VER_SUITE_DATACENTER As Long = &H80
Private Const VER_SUITE_SINGLEUSERTS As Long = &H100
Private Const VER_SUITE_PERSONAL As Long = &H200
Private Const VER_SUITE_BLADE As Long = &H400

Private Type OSVERSIONINFOEX
  dwOSVersionInfoSize As Long
  dwMajorVersion As Long
  dwMinorVersion As Long
  dwBuildNumber As Long
  dwPlatformId As Long
  szCSDVersion As String * 128  ' Maintenance string for PSS usage
  wServicePackMajor As Integer
  wServicePackMinor As Integer
  wSuiteMask As Integer
  wProductType As Byte
  wReserved As Byte
End Type

Private Declare Function GetVersionEx Lib "kernel32" Alias "GetVersionExA" (lpVersionInformation As OSVERSIONINFOEX) As Long


Private Function IsThisTerminalServer() As Boolean
  Dim lRV As Long
  Dim osv As OSVERSIONINFOEX
  Dim bRV As Boolean

  osv.dwOSVersionInfoSize = Len(osv)

  lRV = GetVersionEx(osv)

  If osv.wSuiteMask = VER_SUITE_TERMINAL Then
    bRV = True
  Else
    bRV = False
  End If

  IsThisTerminalServer = bRV
End Function

Private Sub Form_Load()
  Dim ret as Boolean
  ret=IsThisTerminalServer()
  If ret=True Then
    MsgBox "You are running inside terminal server"
  Else
    MsgBox "You are not running inside terminal server"
  End If
End Sub


Submitted By : Nayan Patel  (Member Since : 5/26/2004 12:23:06 PM)

Job Description : He is the moderator of this site and currently working as an independent consultant. He works with VB.net/ASP.net, SQL Server and other MS technologies. He is MCSD.net, MCDBA and MCSE. In his free time he likes to watch funny movies and doing oil painting.
View all (893) submissions by this author  (Birth Date : 7/14/1981 )


Home   |  Comment   |  Contact Us   |  Privacy Policy   |  Terms & Conditions   |  BlogsZappySys

© 2008 BinaryWorld LLC. All rights reserved.