You can also use GetModuleFileName function (Windows). This leaves you with a string with "yourprogram.exe" on the end, so you might need some extra lines of code to chop it down to where you want.
...