Microsoft KB Archive/103036

From BetaArchive Wiki

BUG: AddAtom Causes Divide by Zero Error


The information in this article applies to:

  • Microsoft Windows Software Development Kit (SDK) 3.1


Calling the AddAtom function in the Windows 3.x environment with a string that begins with the pound (#) character causes the system to display the following error message in a system modal dialog:

Application Error

integer divide by 0

This error occurs if the first AddAtom call in the application passes a string containing a # as the first character, and passes non-numeric characters in the rest of the string. For example, the first call to AddAtom with the string "#string" will cause the error to occur.


If it is necessary to have atom strings beginning with the # character, first call AddAtom with a false string that contains no # characters. Alternatively, call InitAtomTable before adding the first atom string beginning with the # character.


Microsoft has confirmed this to be a bug in Windows versions 3.0 and 3.1. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.


Atoms with names begin with the # character are strongly discouraged. The # character serves a special purpose for atoms. If the string that is passed to AddAtom has the form "#1234", AddAtom returns an integer atom whose value is the 16-bit value representation of the decimal number specified in the string. If the decimal value specified is 0 (zero) or a value in the range 0xC000 through 0xFFFF, the return value is zero, indicating an error.

Sample Code

/* Compile options needed:  /Zp /GA or /GD or /Gw */ 

// errant code
 ATOM at;

 at = AddAtom("#string");     // causes error to occur


// corrected code
 ATOM at;


 // or call AddAtom with a false string


 at = AddAtom("#string");     // no error occurs


Additional query words: 3.00 3.10

Keywords :
Issue type :
Technology : kbAudDeveloper kbWin3xSearch kbSDKSearch kbWinSDKSearch kbWinSDK310

Last Reviewed: November 6, 1999
© 2001 Microsoft Corporation. All rights reserved. Terms of Use.