Solved

reference execuatable's  full path

Posted on 1998-01-07
3
224 Views
Last Modified: 2010-04-10
This is an extension to the questions I asked previously.
I need to find out the full path of my executable written in VC.    argv[0] only shows what's typed at the command line, but not including the FULL path.

I tried to use FindExecutable function. Once I included 'shellapi.h".  compile errors are all refering to the shellapi.h.  But I didn't change anything to it.  Any other files I need to include before shellapi.h?

what's the best way to find out the full path of a excutable?  or if you can reference it like you do to the working directory, that'll be good.
0
Comment
Question by:closingcost
  • 2
3 Comments
 

Author Comment

by:closingcost
ID: 1177725
Edited text of question
0
 
LVL 32

Accepted Solution

by:
jhance earned 30 total points
ID: 1177726
You should be able to find the full path from using the information that is available in argv[0].  Remember, there are three ways that the program got found initially.  Either the pathname specified in argv[0] is fully qualified (i.e. C:\x\y\z\file.exe) and it can be found directly.  It may be relative (i.e. ..\x\y\z\file.exe or x\y\z\file.exe) and it can be found by using the current working directory as a base.  Lastly, it may be found from the PATH environment variable which can be searched and the file located.  There is no "magic" way to get the full pathname, but using the above information you can find it the same way that the operating system does.
0
 

Author Comment

by:closingcost
ID: 1177727
OK
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

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

911 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

21 Experts available now in Live!

Get 1:1 Help Now