Open local html file with parameters in default browser in windows

I need to open an html file on a disk with parameters from my C ++ program in the default browser.

For example: c: \ index.html? id = 15.

I use ShellExecute to open all urls or files, but this one does not work, it breaks parameters from local files.

ShellExecute(0, NULL, "file:///c:\index.html?id=15", NULL, NULL, SW_SHOWNORMAL); 

It works fine from the command line, i.e. iexplore file: /// c: \ index.html? id = 15

How can I open this page?

+4
source share
1 answer

Please try this code.

 int result = 0; TCHAR app[MAX_PATH] = { 0 }; result = (int)::FindExecutable(_T("C:\\index.html"), NULL, app); if (result > 32) { ::ShellExecute(0, NULL, app, _T("file:///C:\\index.html?id=15"), NULL, SW_SHOWNORMAL); } 
+1
source

Source: https://habr.com/ru/post/1416371/


All Articles