在浏览器中使用C ++打开HTML文件 [英] Open HTML file in browser using C++
问题描述
我使用Visual studio在C ++中编写程序,我需要做的是创建一个HTML文件并在其中写入数据,然后我希望在浏览器中打开它。现在我可以创建文件,写东西,但我不能打开它,任何人都可以帮助?
I am writing a program in C++ using Visual studio, what I need to do is create an HTML file and write data in it, and then I wish to get it opened in the browser. Right now I can create file, write stuff but I cannot open it, can anyone help?
这可能是一个容易的问题,但我只是一个初学者。 >
It maybe an easy question, but I am just a beginner.
推荐答案
#include <windows.h>
void main()
{
ShellExecute(NULL, "open", "http://dreamincode.net",
NULL, NULL, SW_SHOWNORMAL);
}
http://www.dreamincode.net/code/snippet357.htm
您只需将代码中显示的上述URL替换为绝对路径您的html文件。当然可以使用变量。
http://www.dreamincode.net/code/snippet357.htm You would simply replace the above URL shown in the code with the absolute path of your html file. It could be done with variables of course.
这篇关于在浏览器中使用C ++打开HTML文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!