In Windows, it is stored in the Registry... check here: "HKEY_CURRENT_USER\Software\Bitcoin\Bitcoin-Qt"
There is an entry labelled: "strDataDir" that stores the datadir that Bitcoin-Qt will attempt to use if you do not specify it using the -datadir option on the commandline/shortcut