1. Home
  2. Computing & Technology
  3. Delphi Programming

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

By Zarko Gajic, About.com

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: 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.

Delphi tips navigator:
» Formatting a File Size in Bytes for Display
« Get the Control Under the Mouse in a Delphi application

More Delphi Programming Quick Tips
Zarko Gajic
Guide since 1998

Zarko Gajic
Delphi Programming Guide

Explore Delphi Programming
About.com Special Features

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

Easy ways to connect two computers for networking purposes. More >

  1. Home
  2. Computing & Technology
  3. Delphi Programming
  4. Coding Delphi Applications
  5. Delphi Tips and Tricks
  6. Delphi 2008 Tips
  7. Controlling the Number of a Delphi application Instances on a Terminal Server

©2009 About.com, a part of The New York Times Company.

All rights reserved.