I have two Emacs (Aquamacs and text-based Emacs) on my Mac.
In my .emacs file, I can check if I\'m using Aquamacs with ...
(boundp \'aquamacs-
I know this question was answered a long time ago, but I found another answer by typing emacs --help. This gives a list of options in which you can find emacs --version.
In my case, emacs --version prints: GNU Emacs 24.3.1.
I have only tested this solution on Linux with my current version of Emacs. I do not know if the same solution applies to Windows, or to older versions of Emacs, but in theory it should.