从C++程序启动IE

Jon*_*Jon 4 c++ internet-explorer

我有一个用C++编写的程序,可以进行一些计算机诊断.在程序退出之前,我需要它来启动Internet Explorer并导航到特定的URL.我如何从C++中做到这一点?谢谢.

Mic*_*ICE 9

你在这里......我假设你在这里谈论MSVC++ ......

// I do not recommend this... but will work for you
system("\"%ProgramFiles%\\Internet Explorer\\iexplore.exe\"");


// I would use this instead... give users what they want
#include <windows.h>

void main()
{
     ShellExecute(NULL, "open", "http://stackoverflow.com/questions/982266/launch-ie-from-a-c-program", NULL, NULL, SW_SHOWNORMAL);
} 
Run Code Online (Sandbox Code Playgroud)

  • 另一种获取路径的方法是从注册表,HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\IEXPLORE.EXE,默认值是可执行文件的路径. (3认同)