Solved

Really easy path question

Posted on 1998-08-25
5
204 Views
Last Modified: 2010-04-01
I need to know the path of my application, this is real easy in VB since it has the App.Path object/property. Is there anything like this in C++.
0
Comment
Question by:ds1964
5 Comments
 
LVL 6

Expert Comment

by:thresher_shark
ID: 1171219
Hmm... I'm not sure of any functions that would let you do that.  You could always use the argv[0] variable and then search the computers hard drive for the executable using findfirst and findnext.

Why do you need to know the path of your program anyway?
0
 
LVL 11

Accepted Solution

by:
alexo earned 20 total points
ID: 1171220
GetModuleFilename()
0
 
LVL 2

Expert Comment

by:warmcat
ID: 1171221
If you're working in Win32:

{
   char sz[256];
   ::GetModuleFileName(NULL, sz, sizeof(sz));
}

0
 
LVL 6

Expert Comment

by:thresher_shark
ID: 1171222
Yes, that function seems to do the trick.
0
 

Author Comment

by:ds1964
ID: 1171223
Perfect!! Thanks!!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
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.

867 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

12 Experts available now in Live!

Get 1:1 Help Now