Solved

Finding a path

Posted on 2000-02-29
2
162 Views
Last Modified: 2010-04-02
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.
0
Comment
Question by:rose337
  • 2
2 Comments
 
LVL 22

Accepted Solution

by:
nietod earned 75 total points
Comment Utility
Use GetModuleFileName()

continues.
0
 
LVL 22

Expert Comment

by:nietod
Comment Utility
To use this with CString I believe the following will work

CString Pth;
int Len = 64;

while (true)
{
   char *BufPtr = Pth.GetBuffer(Len);
   int RetVal = GetModuleFileName(NULL,BufPtr,Len)

   Pth.ReleaseBuffer(RetVal);
   if (RetVal != 0 && RetVal < Len) // If buffer was long enough, then
      break;
   Len += 64;
}
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now