Mega Code Archive

 
Categories / Delphi / Ide Indy
 

Controlling the Number of a Delphi application Instances on a Terminal Server

Title: Controlling the Number of a Delphi application Instances on a Terminal Server If you need to control the number of instances of your application that are being executed at one time, there are a few approaches you can take: using a mutex, or creating a file mapping. Both methods (and much more) are explained in the Controlling the number of application instances article. What if your application is run on a Terminal Server Windows Terminal Services environment enables users to access Windows-based programs that are installed on a terminal server. Terminal Services-based servers use the concept of a user session. When multiple users log on to the Terminal Services-based server, there are multiple user sessions. If, to control the number of your instances running (and to communicate between them) you are using file mapping, when the application is running under Terminal Services as a Remote Session the name for the file mapping object can either have "Global\" or "Local\" prefix - to explicitly create the object in the global or session namespace. Your application under Terminal Server Thus, to be able to control the number of instances of your application that is being executed on a terminal server, make sure to: Check if your application is being run under a terminal server, Communicate between applications using file mapping, Make sure that you use "Global\" prefix for the mapping name. Note: The above will work if the user logged into a terminal service session has administrative privileges. Non-admin users do not have enough (SeCreateGlobalPrivilege) privileges to create file mapping - they can access it though. I'm still trying to figure out how to allow a non-admin user to create a file mapping in global session namespace.