Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2000-04-02
1
Medium Priority
?
168 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 150 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

Independent Software Vendors: 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

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…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses

782 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