This is to be expected, you're not doing anything wrong. Windows will not report 4GB ram on a 32bit OS. Here's a quote from an MSDN blog article entitled "The 3GB-not-4GB RAM problem":
Due to an architectural decision made long ago, if you have 4GB of physical RAM installed, Windows is only able to report a portion of the physical 4GB of RAM (ranges from ~2.75GB to 3.5GB depending on the devices installed, motherboard's chipset & BIOS).
GlobaMemoryStatusEx
should work from Windows 2000 and on (later MSDN documents exclude Win2K but earlier ones had it).