[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Finding a path

Posted on 2000-02-29
2
Medium Priority
?
209 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 22

Accepted Solution

by:
nietod earned 300 total points
ID: 2568571
Use GetModuleFileName()

continues.
0
 
LVL 22

Expert Comment

by:nietod
ID: 2568593
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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
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.

649 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