Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2000-04-02
1
Medium Priority
?
167 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

715 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