Advertisement Jump to content
Sign in to follow this  

how do i open a htlm file from a program?

This topic is 4987 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

You need to be more precise?

You simply want to open the file?

A good old fopen should do the job

Share this post

Link to post
Share on other sites
If you simply want to know how to prepare the file for reading with your application and the file you want to open is in the same directory as your executable, you will only need the name of the HTML file for your program to be able to open it.

In C#, you can use the StreamReader class to read in the file.

In C++, you can use ifstream to read the file.

I hope this helps.

Share this post

Link to post
Share on other sites
Do you mean that you'd like to open and read an url on the internet?
If so look up the following functions in MSDN:

InternetOpenUrl / FtpOpenFile

Using these you'd be able to read html/gopher/ftp files and write to ftp's.

Share this post

Link to post
Share on other sites
Guest Anonymous Poster

//use these to open window with html - game documentation



bool GetRegString(LPSTR pszKey, LPSTR pszValue, LPBYTE pszData)
HKEY hKey;
DWORD dwDataSize = MAX_PATH - 1;
DWORD dwValueType = REG_SZ;
DWORD openOK, queryOK;

openOK = RegOpenKeyEx(HKEY_LOCAL_MACHINE, pszKey, 0, KEY_QUERY_VALUE, &hKey);

queryOK = RegQueryValueEx(hKey, pszValue, 0, &dwValueType, pszData, &dwDataSize);

if (pszData[dwDataSize] != '\0') pszData[dwDataSize] = '\0';


return(openOK == ERROR_SUCCESS && queryOK == ERROR_SUCCESS);
} // end of GetRegString()


DWORD launchProcess(char* sProcName, char* sCmdLine) // for launchBrowser()

memset(&wtTSRinfo, 0, sizeof(wtTSRinfo)); // zero the contents of the structure
wtTSRinfo.cb = sizeof(wtTSRinfo); // size of(STARTUPINFO)

if (CreateProcess(sProcName, // lpApplicationName
sCmdLine, // lpCommandLine
FALSE, // BOOL bInheritHandles
0, // creation flags
NULL, // inherit environmental vars from parent
NULL, // inherit CWD from parent
&wtTSRinfo, // gives info about new process
&procInfo)) // receives info about new process
// If your program does not make use of the handles for the new process and
// its primary thread, you should close both right away. Otherwise, even if the
// PROCESS_INFORMATION structure is a local variable and goes out of scope, abandoning
// whatever it contained, the two object entries remain in your process’s object table
// and the system counts them as open handles.
CloseHandle(procInfo.hProcess); // get rid of handles of new process
int x = GetLastError();
MessageBox(NULL, "Process failed to create.", "Error", MB_OK);
MessageBox(NULL, sProcName, sCmdLine, MB_OK);
} // end of launchProcess()


void launchBrowser(char *docpath)
char htmlAssocReg[] = "Software\\CLASSES\\.htm";
char htmlAssoc[_MAX_PATH] = {0};
char browserReg[_MAX_PATH] = {0};
char launchString[4096];
char browser[_MAX_PATH];

GetRegString(htmlAssocReg, NULL, (LPBYTE)htmlAssoc); // get browser name

wsprintf(browserReg, "Software\\CLASSES\\%s\\shell\\open\\command", htmlAssoc);

GetRegString(browserReg, NULL, (LPBYTE)browser); // get browser exe

char* bws = strtok(browser, "\"");

wsprintf(launchString, "%s %s", bws, docpath); // build command line

launchProcess(NULL, launchString);
} // end of launchBrowser()


VOID help_window()
MessageBox(NULL,"Opening Documentation window with your favorite browser", "Fatal Error", MB_OK);



Share this post

Link to post
Share on other sites
Guest Anonymous Poster
He said htlm, not html.

Share this post

Link to post
Share on other sites
Original post by Anonymous Poster
*snippet removed*

That's quite a masochistic way of doing
ShellExecute(NULL, "open", "C:\\mssdk\\samples\\Multimedia\\Direct3D\\Project\\help_doc.htm", NULL, NULL, 0);

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!