String Atoms are useful in DDE(Dynamic Data Exchange). What is the use of Integer Atoms?
-
How old is that exam question? Nobody uses DDE any more. – Martin James Mar 21 '13 at 11:28
-
I use GlobalAddAtom() with RegisterHotKey().where I use string Atom. Integer Atoms is for only backward compatibility or what? – p32 Mar 21 '13 at 11:38
-
1@Martin James: String atoms are not using only in DDE. – Xearinox Mar 21 '13 at 11:57
2 Answers
Using integer and string atoms is similar, but integer atoms do NOT have a reference count, so they are actually never stored in the atom table, but mapped directly to the atom value instead.
Example of String Atoms: Windows class names (but they also may use Integer Atom, see Hans Passant's answer)
Example of Integer Atoms: Standard clipboard formats
The only use I know of are the atom numbers for built-in dialog class names. MessageBox, and others, use #32770. Which is what you use to find the window back. There are some others, I happily forgot their numbers and usage. This goes back to the 1980s, the days of 16-bit Windows and extreme resource limitations.
You can see sample code that uses this atom number in this answer.
// Checks if <hWnd> is a dialog
StringBuilder sb = new StringBuilder(260);
GetClassName(hWnd, sb, sb.Capacity);
if (sb.ToString() != "#32770") return true;
[EDIT]
Added some integer atom classes:
#ifndef POPUPMENU_CLASS_NAME
#define POPUPMENU_CLASS_NAME "#32768" /* PopupMenu */
#endif
#ifndef DESKTOP_CLASS_NAME
#define DESKTOP_CLASS_NAME "#32769" /* Desktop */
#endif
#ifndef DIALOG_CLASS_NAME
#define DIALOG_CLASS_NAME "#32770" /* Dialog */
#endif
#ifndef WINSWITCH_CLASS_NAME
#define WINSWITCH_CLASS_NAME "#32771" /* WinSwitch */
#endif
#ifndef ICONTITLE_CLASS_NAME
#define ICONTITLE_CLASS_NAME "#32772" /* IconTitle */
#endif

- 1
- 1

- 922,412
- 146
- 1,693
- 2,536
-
In MSDN "Rather than copying the string into each structure, the application can place the string in the atom table…" So Integer Atom is all about to save few block of memory.w0w – p32 Mar 21 '13 at 14:07