Consultor Eletrônico



Kbase 17290: Another Way to Stop Users From Opening Multiple App Copies
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   10/05/1998
Another Way to Stop Users From Opening Multiple App Copies

The normal way to keep your users from opening multiple instances of
your application is to use the FindWindow API to see if any window
with a certain title already exists. If it does, then you can just
show that window and terminate the new instance the user tried to
bring up.

However, that will not work if you dynamically change the title bar
text in your windows (unless, of course, you want to insert code that
would check for all possible title bar names).

So, what can you do?

Well, you can take a look at the following knowledgebase entries and
from them you can build a bit of code that uses Atoms to accomplish
what you want.

Basically, when an application starts up, it would check the global
atom table for a specific string. If that string exists, it would
notify the user that a copy is already open and then exit. It the
string does not exist, the application would add it to the table and
then proceed to initialize normally. When the application shuts down
it should remove the atom from the global atom table.


17143 WIN32 API - What exactly is an Atom?
17144 How to Call WIN32 API Function: GlobalAddAtom
17145 How to Call WIN32 API Function: GlobalDeleteAtom
17146 How to Call WIN32 API Function: GlobalFindAtom
17147 How to Call WIN32 API Function: GlobalGetAtomName

Progress Software Technical Support Note # 17290