ATOM GlobalDeleteAtom(atm) | ||||
ATOM atm; | /* atom to delete, */ |
The GlobalDeleteAtom function decrements (decreases by one) the reference count of a global atom. If the atom's reference count reaches zero, the string associated with the atom is removed from the system atom table.
atm
Identifies the atom to be deleted.
The return value is zero if the function is successful. The return value is equal to the atm parameter if the function failed to decrement the reference count for the specified atom.
An atom's reference count specifies the number of times the string has been added to the atom table. The GlobalAddAtom function increments (increases by one) the reference count each time it is called with a string that already exists in the system atom table.
The only way to ensure that an atom has been deleted from the atom table is to call this function repeatedly until it fails. When the count is decremented to zero, the next GlobalFindAtom or GlobalDeleteAtom function call will fail.
The following example repeatedly calls the GlobalDeleteAtom function to decrement the reference count for the atom until the atom is deleted and the GlobalDeleteAtom function does not return zero:
int cRef;
ATOM atom;
char szMsg[80];
for (cRef = 0; ((atom = GlobalFindAtom("This is a global atom")) != 0);
cRef++)
GlobalDeleteAtom(atom);
wsprintf(szMsg, "reference count was %d", cRef);
MessageBox(hwnd, szMsg, "GlobalDeleteAtom", MB_OK);