使用C++在浏览器中打开 HTML 文件
Open HTML file in browser using C++
我正在使用Visual studio编写C++程序,我需要做的是创建一个HTML文件并在其中写入数据,然后我希望在浏览器中打开它。现在我可以创建文件,写东西,但我无法打开它,有人可以帮忙吗?
这可能是一个简单的问题,但我只是一个初学者。
#include <windows.h>
void main()
{
ShellExecute(NULL, "open", "http://dreamincode.net",
NULL, NULL, SW_SHOWNORMAL);
}
http://www.dreamincode.net/code/snippet357.htm您只需将代码中显示的上述 URL 替换为 html 文件的绝对路径即可。当然,这可以用变量来完成。
void CAboutDlg::OnButton1()
{
CString strDir;
char buffer[255];
GetCurrentDirectory(255, buffer);
strDir = buffer;
strDir.TrimRight("\");
strDir += "\";
strDir += _T("helpindex.html");
if( 32 >= (int)ShellExecute( NULL, "open", strDir, NULL, NULL, SW_SHOWNORMAL))
{
AfxMessageBox("::ShellExecuteFailed"
" to open this link!");
}
}
试试这个...它对我来说效果很好...
#include <windows.h>
void main()
{
LPCTSTR helpFile = "chelphelpFile.html";
ShellExecute(NULL, "open", helpFile, NULL, NULL, SW_SHOWNORMAL);
system("PAUSE");
}
如果你正在为 UWP 进行开发:
Windows::System::Launcher::LaunchUriAsync(ref new Uri("https://www.google.com"));
相关文章:
- 如何使用PHP将上传到本地主机的一个html文件重定向到磁盘上的另一个html文档
- 如何在C++中正确地将我的语言字符输出到HTML文件中
- 编写一个 C++ 程序以将文本文件转换为 HTML 文件
- 如何以C++格式输出已保存.html文件中<a href>标签中的所有链接?
- 将图形插入C 中的HTML文件
- 使用C 将JPG文件添加到输出的HTML文件中
- 如何在 c++ 中的 HTML 文件中插入图像
- 如何在twebbrowser组件中显示HTML文件
- 在带有 C++ 的目录中打开 HTML 文件
- 使用 c++/boost::regex 提取 HTML 文件的特定部分
- ShellExecute 未打开 HTML 文件
- 在 linux 中使用 log4cplus 在 html 文件中写入日志C++
- 使用Win32/MFC将HTML文件转换为PDF
- 为什么它只打印文本文件的一个单词,而不是将整个文本文件打印到html文件中
- 使用C++在浏览器中打开 HTML 文件
- 如何使用 ShellExecute 通过 C++ 在 Windows 中打开 html 文件
- Qt:如何以纯文本形式打开Html文件
- 通过 tcp 和浏览器发送带有 HTTP 协议的 html 文件会显示错误
- 如何使用activex控件在窗口/对话框中呈现html文件
- 如何从流中加载html内容,然后如何创建样式表以在预览窗格中显示html文件(如html预览处理程序)