rose337
asked on
Finding a path
Hi, when I run my app, I would like a CString variable to contain the path of the apps executable that is running. That is, c:\program files\test.exe where test.exe is the app that is running. The complication is that the app will be running in different paths depending on the PC that is running it. So the this CString variable must dynamically find its own path.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
CString Pth;
int Len = 64;
while (true)
{
char *BufPtr = Pth.GetBuffer(Len);
int RetVal = GetModuleFileName(NULL,Buf
Pth.ReleaseBuffer(RetVal);
if (RetVal != 0 && RetVal < Len) // If buffer was long enough, then
break;
Len += 64;
}