Solved

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

Posted on 2000-04-02
1
160 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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
cat dog challenge 18 122
bobThere java chalenge 45 84
Installing Microsoft R server on REDHAT or SUSE Linux 4 125
sumHeights2  challenge 7 76
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

706 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

17 Experts available now in Live!

Get 1:1 Help Now