Reputation: 23275
How can you detect whether the current session is a Terminal Services (Remote Desktop) session in a VB6 app?
Upvotes: 0
Views: 3469
Reputation: 1
I had the same problem. As far as I understood, your form placed what you want where you wanted it (e.g. in the center of the screen). Your application works fine on a normal desktop, but it will be maximized in terminal environment. If so, I found a little trick. Put a timer on that form, make its interval=1
and write in timer1_timer
event
Me.WindowState = 0
'then put the movement code like this
formname.Top = (Screen.Height / 2) - (formname.Height / 2) -400 '(400 for form title bar)
formname.Left = (Screen.Width / 2) - (formname.Width / 2)
timer1.interval=0
timer1.enabled=false
That's it. [email protected]
Upvotes: 0
Reputation: 244782
Calling the GetSystemMetrics
function with the SM_REMOTESESSION
flag will tell you whether the app is running inside a Terminal Services session.
To call that from VB 6, you need to declare it in a module like so:
Const SM_REMOTESESSION As Long = &H1000
Declare Function GetSystemMetrics Lib "user32" (ByVal nIndex As Long) As Long
If you are running inside of a Terminal Services environment, the return value will be non-zero.
...But you should really just fix your centering code, rather than trying to work around it with different behavior depending on whether you're running inside a Terminal Services session. That's just going to make more work for you and introduce more bugs. Unfortunately, I can't tell you what's wrong with the centering code you're using without seeing it.
Upvotes: 3