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]; _snprintf(szUrl, sizeof(szUrl), "file://%s", szFile); return WebPage(hwndParent, szUrl); } ExampleUse() { LocalWebPage(NULL, "c:\\temp\\hello.html"); }
Programming Tips - Win32: Display a local HTML file in the default browser
Date: 2008jul17
Updated: 2023mar29
Platform: win32
OS: Windows
Language: C/C++
Keywords: web, page, webpage, local
Q. Win32: Display a local HTML file in the default browser
A. Simulate the user clicking on it like this: