Are you asking the right question?
If you are wanting where the program is being executed, you should use GetCurrentDirectory
GetCurrentDirectory function
http://msdn.microsoft.com/en-us/library/windows/desktop/aa364934%28v=vs.85%29.aspx
or the equivalent CRT call, _getcwd
_getcwd, _wgetcwd
http://msdn.microsoft.com/en-us/library/sf98bd4y%28v=vs.100%29.aspx
But the current (or working) directory is not always the same as the directory where the excutable file is located.
The approach you are using is the directory where the executable file for the current process is located. If this is the directory you want, then after you have got the full module path using GetModuleFileName you can then use either:
1. std::string functions (as DTSCode suggested)
2. equivalent C library calls (e.g. strrchr)
3. _splitpath and _makepath CRT calls
4. PathRemoveFileSpec from the Path API
Where 4 is prob the most up to date Windows way to do it (or PathCchRemoveFileSpec, if you want to be secure.)
By the way, why do you need to know this folder? For example, if it's to do with storing data, then you should prob. be using a different approach on Windows (which starts off with SHGetKnownFolderPath or SHGetFolderPath.)
Andy
strrchr
http://www.cplusplus.com/reference/cstring/strrchr/
_splitpath, _wsplitpath
http://msdn.microsoft.com/en-us/library/e737s6tf%28v=vs.100%29.aspx
_makepath, _wmakepath
http://msdn.microsoft.com/en-us/library/sh8yw82b%28v=vs.100%29.aspx
PathRemoveFileSpec function
http://msdn.microsoft.com/en-us/library/windows/desktop/bb773748%28v=vs.85%29.aspx