Solved

reference execuatable's  full path

Posted on 1998-01-07
3
235 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
[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
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
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 learn how to clear a vector as well as how to detect empty vectors in C++.

733 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