ATOM

From ReliCodia

(Difference between revisions)
Revision as of 01:54, 28 November 2004
216.231.56.29 (Talk | contribs)

← Previous diff
Revision as of 01:59, 28 November 2004
216.231.56.29 (Talk | contribs)

Next diff →
Line 1: Line 1:
-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 [[API:AddAtom|AddAtom]], or to the blobal repository by calling [[API:GlobalAddAtom|GlobalAddAtom]], you get back a process-wide or system-wide identifier, called an atom. +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 [[API:AddAtom|AddAtom]], or to the blobal repository by calling [[API:GlobalAddAtom|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, [[API:GetAtomName|GetAtomName]] or [[API:GlobalGetAtomName|GlobalGetAtomName]]. You can easily pass this atom around--it's just a WORD--and everybody can translate it back to string by calling, respectively, [[API:GetAtomName|GetAtomName]] or [[API:GlobalGetAtomName|GlobalGetAtomName]].

Revision as of 01:59, 28 November 2004

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 blobal 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 Windows 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).