Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C++ and Visual C++ > Visual C++
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 22nd, 2003, 08:35 AM
Friend of Wrox
 
Join Date: Jun 2003
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
 
Old October 22nd, 2003, 10:47 AM
Authorized User
 
Join Date: Aug 2003
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Try setting a CString equal to m_pszHelpFilePath

ie. CString sPath = m_pszHelpFilePath;
 
Old October 23rd, 2003, 02:01 PM
Friend of Wrox
 
Join Date: Jun 2003
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
 
Old October 23rd, 2003, 02:47 PM
Authorized User
 
Join Date: Aug 2003
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.

 
Old October 23rd, 2003, 02:51 PM
Friend of Wrox
 
Join Date: Jun 2003
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
 
Old October 23rd, 2003, 03:06 PM
Authorized User
 
Join Date: Aug 2003
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...

 
Old October 24th, 2003, 06:30 AM
Authorized User
 
Join Date: Aug 2003
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);

...
}






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 04: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





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.