Dave's Brain

Browse - programming tips - win32 local web page

Date: 2008jul17
Platform: win32

Q.  I want to display a local HTML file in the default browser.
How can I simply do that.

A.  Simulate the user clicking on it like this:

BOOL WebPage(const HWND hwndParent, LPCSTR szUrl)
{
	return ShellExecute(hwndParent, "open", szUrl, NULL, NULL, SW_SHOWNORMAL) > (HINSTANCE) 32;
}

BOOL LocalWebPage(const HWND hwndParent, LPCSTR szFile)
{
	char	szUrl[MAX_PATH*2+1];

	_snprintf(szUrl, sizeof(szUrl), "file://%s", szFile);
	return WebPage(hwndParent, szUrl);
}

ExampleUse()
{
	LocalWebPage(NULL, "c:\\temp\\hello.htm");
}
What this info useful to you? You can donate to say thanks

Add a comment

Sign in to add a comment
Copyright © 2008-2012, dave - Code samples on Dave's Brain is licensed under the Creative Commons Attribution 2.5 License. However other material, including English text has all rights reserved.
Advertisements: