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
Solved

reference execuatable's  full path

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

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…
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…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

856 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