ATOM

From ReliCodia

Windows provides repositories for strings--the atom tables. There is a local, per-process, atom table; and a global, system-wide, atom table. When you add a string to the local repository by calling AddAtom, or to the global repository by calling GlobalAddAtom, you get back a process-wide or system-wide identifier, called an atom. If the string is already present, the same identifier is returned with each call to [Global]AddAtom (the reference count is increased, though).

You can easily pass this atom around--it's just a WORD--and everybody can translate it back to string by calling, respectively, GetAtomName or GlobalGetAtomName.

You can also search atom tables for a given string using, respectively, FindAtom or GlobalFindAtom.

Global atoms are a cheap way of passing limited-size strings between applications. For instance, they can be passed as WPARAMs in registered Window Messages.

Atoms are reference counted. Every call to [Global]AddAtom increases the atom's reference count. To free an atom, each client should call DeleteAtom or GlobalDeleteAtom, respectively.

One can also store integers in the atom table using the macro MAKEINTATOM.

Note: This is a primitive mechanism (string sizes are limited to 255 characters), created mostly for Windows simplistic inter-process communication system called DDE. Modern version of Windows have better inter-process communication mechanisms (for instance, memory-mapped files).