ATOM AddAtom(lpszName) | |||||
LPCSTR lpszName; | /* address of string to add | */ |
The AddAtom function adds a character string to the local atom table and returns a unique value identifying the string.
lpszName
Points to the null-terminated character string to be added to the table.
The return value specifies the newly created atom if the function is successful. Otherwise, it is zero.
The AddAtom function stores no more than one copy of a given string in the atom table. If the string is already in the table, the function returns the existing atom value and increments (increases by one) the string's reference count.
The MAKEINTATOM macro can be used to convert a word value into a string that can be added to the atom table by using the AddAtom function.
The atom values returned by AddAtom are in the range 0xC000 through 0xFFFF.
Atoms are case-insensitive.
The following example uses the AddAtom function to add the string “This is an atom” to the local atom table:
ATOM at;
char szMsg[80];
at = AddAtom("This is an atom");
if (at == 0)
MessageBox(hwnd, "AddAtom failed", "", MB_ICONSTOP);
else {
wsprintf(szMsg, "AddAtom returned %u", at);
MessageBox(hwnd, szMsg, "", MB_OK);
}