Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > C# and C > C++ and Visual C++ > Visual C++
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Visual C++ Questions specific to Microsoft's Visual C++. For questions not specific to this Microsoft version, use the C++ Programming forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Visual C++ section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old October 22nd, 2003, 08:35 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: McPherson, Kansas, USA.
Posts: 128
Thanks: 0
Thanked 0 Times in 0 Posts
Default Getting the application path

I am looking for a function that will return the path the application is installed in.

This is different than GetCurrentDirectory.

Thanks for your help.



Larry Asher
__________________
Larry Asher
Reply With Quote
  #2 (permalink)  
Old October 22nd, 2003, 10:47 AM
Authorized User
 
Join Date: Aug 2003
Location: Cary, NC, USA.
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Try setting a CString equal to m_pszHelpFilePath

ie. CString sPath = m_pszHelpFilePath;
Reply With Quote
  #3 (permalink)  
Old October 23rd, 2003, 02:01 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: McPherson, Kansas, USA.
Posts: 128
Thanks: 0
Thanked 0 Times in 0 Posts
Default

That might work if I had a variable named m_pszHelpFilePath. There should be a way to return the application path. You can do it in VB.

To date, I am a little disappointed with VC++. I have really looked forward to working with the language. I know that some of my frustration is due to the learning curve but others are just the amount of work required to perform some of the simplist task.

Any help you all can provide will be greatly appreciated.

Thanks,

Larry Asher
Reply With Quote
  #4 (permalink)  
Old October 23rd, 2003, 02:47 PM
Authorized User
 
Join Date: Aug 2003
Location: Cary, NC, USA.
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Actually, if you have an application class in your project then the m_pszHelpFilePath variable is present. Try it out! I used it in my CabcApp::InitInstance() function that is added by class wizard.

Reply With Quote
  #5 (permalink)  
Old October 23rd, 2003, 02:51 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: McPherson, Kansas, USA.
Posts: 128
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hey, it is not there! Beside that is really a hokey work around. I am looking for a real solution. Shouldn't be that difficult.

Good luck.

Larry Asher
Reply With Quote
  #6 (permalink)  
Old October 23rd, 2003, 03:06 PM
Authorized User
 
Join Date: Aug 2003
Location: Cary, NC, USA.
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hey!!! It is there!!! Look up CWinApp::m_pszHelpFilePath in Help. Or try somthing like this:

char buf[MAX_PATH];
GetCurrentDirectory(MAX_PATH, buf);
CString sCurrentDir = buf;

Have you actually tried surfing google on this topic it seems like it would be fairly easy to find.

About your comment on VC++. It just takes a while coming from VB because things that were easy to do in VB are not easy to do in VC...but VC is much more powerful and a tighter/cleaner way of programming. I myself programmed in VB for a couple of years and would never turn back to it now. Object Oriented programming creates great code. Good Luck...

Reply With Quote
  #7 (permalink)  
Old October 24th, 2003, 06:30 AM
Authorized User
 
Join Date: Aug 2003
Location: Cary, NC, USA.
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Larry, I forgot that in your original post you said that it is not GetCurrentDirectory...I really think you are looking to use the m_pszHelpFilePath variable. What you do is get the path it gives you and trim off the filename at the end. This WILL get the path to where ever the application is running from.

BOOL CWhateverApp::InitInstance()
{
CString sCurrentDir = m_pszHelpFilePath;
sCurrentDir = sCurrentDir.Left(sCurrentDir.ReverseFind('\\'));

// You can test it by adding this line
AfxMessageBox(sCurrentDir, 32);

...
}

Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Search for Application Path jmss66 VB How-To 1 July 2nd, 2008 03:30 PM
Need Help with path for loading Pics (app.path) Tabbasum Beginning VB 6 2 November 15th, 2007 03:57 AM
using app.path in database path and filename kd8con VB Databases Basics 2 October 25th, 2006 11:45 AM
The virtual path maps to another application deeptisingh20 ASP.NET 1.0 and 1.1 Basics 2 August 8th, 2006 07:05 AM
Application path Dsypher C# 2005 1 October 8th, 2005 07:31 AM



All times are GMT -4. The time now is 05:15 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.