![]() |
limiting number of instances in Windows terminal server
Hello,
I can read a little of German, but to write, not possible. So here is my question in English: I have Delphi app which need to execute in Windows Terminal Server (nowdays RDS). We would like to be able to control how many instances user can run in their session. So for example: - user 1 can run two instances of app 1 - user 2 can run 1 instance of app 1 We are able to fix this on Windows to have only one instance of application running but on TS is a bit problem for us. Anybody had similar problem? Thank you. |
AW: limiting number of instances in Windows terminal server
Do you use a mutex?
If yes, a global or a session mutex? |
AW: limiting number of instances in Windows terminal server
Zitat:
![]() |
AW: limiting number of instances in Windows terminal server
Zitat:
|
AW: limiting number of instances in Windows terminal server
Zitat:
|
AW: limiting number of instances in Windows terminal server
Zitat:
![]() |
AW: limiting number of instances in Windows terminal server
Zitat:
|
AW: limiting number of instances in Windows terminal server
Zitat:
|
AW: limiting number of instances in Windows terminal server
Zitat:
Zitat:
|
AW: limiting number of instances in Windows terminal server
Zitat:
|
AW: limiting number of instances in Windows terminal server
Zitat:
For Terminal Server (or even in generell) do not use a global mutex as this would be for the whole system. For an application with one instance you need one mutex. For an application with two instances you need two mutexes. ... |
AW: limiting number of instances in Windows terminal server
.. but whith muutexes you have to decide how many instances can be started - at design time.
These settings are then based on application level - not on user level. best regards Klaus |
AW: limiting number of instances in Windows terminal server
Did you try TJvAppInstances already? It is designed for limiting app instances, and it allows to set the maximum number of simultaneous instances using the property
![]() |
AW: limiting number of instances in Windows terminal server
Zitat:
Delphi-Quellcode:
Using usernames and an appended counter instead is trivial. Reading the information that user A can start the application X times and user B can start it only once is trivial, too (Registry, INI, XML, whatever). Use that in conjunction with a for-loop that tries to create mutexes until either all of them already exist, or the maximum allowed instances are reached, and you have reached your goal.
hMutex:= CreateMutex(nil, True, PRODUCTNAME + PRODUCTNAME + PRODUCTCOPYRIGHT);
Regards Dalai |
AW: limiting number of instances in Windows terminal server
Zitat:
- I have to list processes in TS session - I have to get username from TS enviroment which is logged in and simple compare number of instances in question with number of those processes already running. Is this wrong approach ? Yet to figure out how to read logged user and processes over Win32 API :-(. |
AW: limiting number of instances in Windows terminal server
Yes, reading the number of processes running as user X is another possible approach. Unfortunately I don't know how to read the user a process runs as, even less when TS is involved.
Regards Dalai |
AW: limiting number of instances in Windows terminal server
Hello,
use a GUID as (global) Mutex-Name with _1, _2 and so on. if _1 is used, use _2. if _x is used, you have your maximum instances ... quick&dirty ;) or just said: use JEDI JvAppInst.pas hey use some form of hidden window for each instance |
AW: limiting number of instances in Windows terminal server
Zitat:
Code:
(based on
private static int CountApplicationInstances()
{ var currentProcess = Process.GetCurrentProcess(); var processes = Process.GetProcessesByName(currentProcess.ProcessName); // test if there's another process running in current session. var intTotalRunningInCurrentSession = processes.Count(prc => prc.SessionId == currentProcess.SessionId); return intTotalRunningInCurrentSession; } ![]() |
AW: limiting number of instances in Windows terminal server
Zitat:
![]() |
AW: limiting number of instances in Windows terminal server
Zitat:
![]() ![]() I also posted another suggestion (see #18) |
AW: limiting number of instances in Windows terminal server
Zitat:
|
AW: limiting number of instances in Windows terminal server
Delphi-Quellcode:
will limit the applications inside the SESSION.
TJvAppInstances
So => yes, this will work on TS too. But, a single user can open more than one session on a TS (you can limit it optional to only one session per user). |
AW: limiting number of instances in Windows terminal server
Zitat:
|
AW: limiting number of instances in Windows terminal server
Zitat:
The main problem in this scenario is how to deal with unexpected termination of the program holding the licence. In this case the licence is not properly returned to the server for later reuse. How to handle that depends on specifics of the environment. You can, for example, implement a mechanism that allows the server to check at intervals whether the processes having a licence in use are still running. Or you can require the program to regularly "renew" the claim they have on a licence, e.g. at 10 minute intervals. The licence is then reset to available if two of these intervals have passed without a renewal of the licence. |
AW: limiting number of instances in Windows terminal server
Zitat:
|
AW: limiting number of instances in Windows terminal server
Zitat:
|
AW: limiting number of instances in Windows terminal server
Zitat:
|
Alle Zeitangaben in WEZ +1. Es ist jetzt 15:18 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz