>>What I further found out:
>>- The maximum size for the stringtype key/info is 256 bytes, I believe.
>>- Each redeclaration (with GlobalAddAtom) of the same atom name increases what might be called a 'stack number'. Each delte (with GlobalDeleteAtom) decreases it. So, the most secure way to get rid of the entry is:
do while GlobalFindAtom( cString ) > 0
>> GlobalDeleteAtom( nAtom )
>>enddo
>
>It seems to me that this would be an abuse of the original idea of using atoms - which might cause some problems.
>
>What I briefly read some years ago - assuming I read and understood it correctly - is more or less the following.
>
>Atoms are used for efficient storage of strings. Each time you create an atom, with the corresponding functions, Windows will check whether an identical string already exists. If it does, the same space will be used again. If it doesn't, a new atom will be created.
>
>So, it would seem to me that any function must use GlobalAddAtom() to define the string, and a single invocation of GlobalDeleteAtom() to release it. Then, if another program or process happens to still use it, it will remain in memory, as it should.
>
>Reducing the usage count to zero would be an indication that no process, not the one you are currently in, and no other process, uses the specific string any longer.
I agree. Normally, one should use a quite unique string.
Here's a nice piece of code (
http://www.news2news.com/vfp/?group=-1&function=167 Anatoliy Mogylevets)
#DEFINE AtomStrLength 512
DECLARE INTEGER GlobalGetAtomName IN kernel32;
INTEGER nAtom,;
STRING @ lpBuffer,;
INTEGER nSize
CREATE CURSOR cs (atom N(12), strlen N(5), name C(250))
FOR nAtom = 49152 TO 65535
lpBuffer = Repli(Chr(0), AtomStrLength)
lnResult = GlobalGetAtomName (nAtom, @lpBuffer, AtomStrLength)
IF lnResult > 0
INSERT INTO cs VALUES (nAtom, lnResult, LEFT(lpBuffer, lnResult))
ENDIF
ENDFOR
SELECT cs
GO TOP
BROW NORMAL NOWAIT
Groet,
Peter de Valença
Constructive frustration is the breeding ground of genius.
If there’s no willingness to moderate for the sake of good debate, then I have no willingness to debate at all.
Let's develop superb standards that will end the holy wars.
"There are three types of people: Alphas and Betas", said the beta decisively.
If you find this message rude or offensive or stupid, please take a step away from the keyboard and try to think calmly about an eventual a possible alternative explanation of my message.