我需要在Microsoft Edge中打开URL(在Windows 10上).当我调用
start shell:AppsFolder\Microsoft.MicrosoftEdge_8wekyb3d8bbwe!MicrosoftEdge http://www.google.com
Run Code Online (Sandbox Code Playgroud)
然后Microsoft Edge正确启动但它不会打开给定的URL(在本例中为www.google.com).它会打开Bing搜索,而不是将给定的URL用作搜索词.
我尝试了使用代码中的 URL 启动 Microsoft Edge和如何从命令行在 Microsoft Edge 中打开 URL 中的解决方案?但它们对我不起作用。
这是我的代码:
std::string url = "http://www.test.com";
std::wstring quotedArg = L"microsoft-edge:\"" + url + L"\"";
std::vector<WCHAR> argBuff(quotedArg.w_size() + 1);
wcscpy_s(&argBuff[0], argBuff.size(), quotedArg.w_str());
STARTUPINFO si = {0};
PROCESS_INFORMATION pi = {0};
si.cb = sizeof si;
si.dwFlags = STARTF_USESHOWWINDOW;
si.wShowWindow = SW_SHOWNORMAL;
if (!CreateProcess(L"start", &argBuff[0], NULL, NULL, FALSE,
0, NULL, NULL, &si, &pi)) {
DWORD error = GetLastError(); // here error = 2
return false;
}
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread); …Run Code Online (Sandbox Code Playgroud)