well the first bit's easy - use the GlobalMemoryStatus API call. you have to pass a structure that's filled with the info - use API viewer to get the declares.
I'm not sure about the second bit, it's dangerous, better to leave it to windows (although it does a crap job of managing memory)