在Windows上的默认浏览器中使用参数打开本地html文件 [英] Open local html file with parameters in default broswer on windows

查看:171
本文介绍了在Windows上的默认浏览器中使用参数打开本地html文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要使用默认浏览器中C ++程序中的参数打开磁盘上的html文件。

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

例如:c:\index.html?id = 15。

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

我正在使用ShellExecute,打开所有的url或文件,但是此操作不起作用,它会从本地文件中删除参数。

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

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

在命令行中可以正常工作,即
iexplore file:/// c:\ index.html?id = 15

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

如何打开该页面?

推荐答案

请尝试使用此代码。

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);
}

这篇关于在Windows上的默认浏览器中使用参数打开本地html文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆