Einzelnen Beitrag anzeigen

mjustin

Registriert seit: 14. Apr 2008
3.006 Beiträge
 
Delphi 2009 Professional
 
#18

AW: limiting number of instances in Windows terminal server

  Alt 5. Jun 2019, 10:00
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.
It is easy to count the instances running in the current session. Example in .Net:

Code:
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;
    }
(based on https://stackoverflow.com/a/36210660/80901)
Michael Justin
habarisoft.com
  Mit Zitat antworten Zitat