Solved

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

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

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Login Script to Copy Folders 12 51
Macro to save highlighted rows as a separate file 5 51
Smart Camera scanning and reading information 3 127
Work with App store 7 122
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
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.
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…
Suggested Courses

738 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