How can I get just the path for where my program is running?

ie. "C:\windows\money.exe"

i want to get just: "C:\windows\money
Who is Participating?
bbousquetConnect With a Mentor Commented:
I suggest you take a look at the following Win32 API functions:

HMODULE GetModuleHandle(LPCTSTR lpModuleName);

and then:

DWORD GetModuleFileName(HMODULE hModule, LPTSTR lpFilename, DWORD nSize);


DWORD GetModuleFileNameEx(HANDLE hProcess, HMODULE hModule, LPTSTR lpFilename, DWORD nSize);

These function calls are pretty straightforward and you shouldn't have any problems getting your application's path with that.
scooter1Author Commented:
Yeah that's the prob. I am having trouble with those i tried: GetModuleFileName()

which worked but it gave me the filename as well, the others i can't get.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.