Solved

Opening HTML file in browser where HTML is in same directory as executable

Posted on 2000-04-02
1
162 Views
Last Modified: 2013-11-20
I created a bunch of HTML help files, and now I would like to have a browser window open when I click on the Help button.  I tried ShellExecute, and it works when I give it a URL like "C:\blah\index.htm", but I want it to open index.htm that resides in the same directory as the executable that is running.  I tried just "index.htm" and ".\\index.htm" in the ShellExecute command, but to no avail.  Can someone help me out?
0
Comment
Question by:tarlochanD
1 Comment
 
LVL 23

Accepted Solution

by:
chensu earned 50 total points
ID: 2678923
// get the full path name of a file that is in the same
// directory as this executable file
TCHAR pszFullPathName[MAX_PATH];

// get the full path name of the executable file
::GetModuleFileName(NULL,
                    pszFullPathName,
                    sizeof(pszFullPathName) / sizeof(TCHAR));

// get the address of the filename portion of the full path
LPTSTR lpszFileName;  // point to the filename portion of the full path
::GetFullPathName(pszFullPathName,  // filename
                  sizeof(pszFullPathName) / sizeof(TCHAR),
                  pszFullPathName,  // path
                  &lpszFileName);
   
// replace the filename portion with the desired filename
::lstrcpy(lpszFileName, _T("index.htm"));

::ShellExecute(hWnd, NULL, pszFullPathName, NULL, NULL, SW_SHOWNORMAL);
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

Suggested Solutions

Title # Comments Views Activity
Decoding 32 bit binary streams 6 37
Generic progress indicator 6 113
matchUp  challenge 6 53
NotAlone Challenge 20 80
Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

920 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

14 Experts available now in Live!

Get 1:1 Help Now