以下文件test.cc是使用特定URL启动Microsoft Edge:
#include <Windows.h>
int main()
{
SHELLEXECUTEINFOW sei = { sizeof sei };
sei.lpVerb = L"open";
sei.lpFile = L"microsoft-edge:http://www.stackoverflow.com";
ShellExecuteExW(&sei);
}
编译:
cl test.cc /link shell32.lib
它适用于Windows 10(Edge打开到特定URL),但在Windows Server 2016中,此程序会弹出一个错误窗口:
标题:microsoft-edge:http://www.stackoverflow.com
内容:This file does not have a program associated with it for performing this action. Please install a program or, if one is already installed, create an association in the Default Programs control panel.
我在控制面板中选中了“默认程序”,并在Microsoft Edge页面中选择了“将此程序设置为默认程序”。