微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

通过System打开时Edge First Tab错误

如何解决通过System打开时Edge First Tab错误

这样做

const std::string LaunchStr = "C:\\\"Program Files (x86)\"\\Microsoft\\Edge\\Application\\msedge.exe --profile-directory=\"Profile 1\" C:\\Users\\redacted1\\redacted4.html";
System(LaunchStr.c_str());

Microsoft Edge将按预期启动,加载的配置文件是正确的配置文件,并且redacted4.html上有一个新选项卡。但是,第一个标签(也是重点标签)是以下URL program%20--fast-start%20files%20%28x86%29/Microsoft/Edge/Application/msedge.exe。我觉得很奇怪,因为我在代码中什么地方都没有写program%20--fast-start%20files%20%28x86%29/

那是为什么?我该如何预防?

解决方法

我建议您尝试参考下面的示例代码,以帮助您使用正确的配置文件和指定的URL正确启动MS Edge浏览器。

#include <windows.h>

int main()
{
    CoInitializeEx(nullptr,COINIT_APARTMENTTHREADED);

    SHELLEXECUTEINFOW sei = { sizeof sei };
    sei.lpVerb = L"open";
    sei.lpFile = L"C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe";
    sei.lpParameters = L"--user-data-dir=\"C:\\Users\\<user>\\AppData\\Local\\Microsoft\\Edge\\User Data\\Profile 1\" C:\\Users\\redacted1\\redacted4.html"; // Modify the path for user-profile here...
    ShellExecuteExW(&sei);
}

注意:您可以在Edge浏览器的地址栏中键入edge://version/,并在上述代码示例中查看配置文件路径以对其进行修改。

输出:

enter image description here

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。