![]() |
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) |
Alle Zeitangaben in WEZ +1. Es ist jetzt 19:50 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