Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/155.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/url/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何从c++;windows中的程序? 我希望我的C++代码打开一个URL。但是所有的线程都使用已经指定的URL来促进使用SeLeExcReST。我的代码要求用户输入url,然后程序必须在浏览器中打开它,以便url是字符串形式。 非常感谢。_C++_Url_Shellexecute - Fatal编程技术网

如何从c++;windows中的程序? 我希望我的C++代码打开一个URL。但是所有的线程都使用已经指定的URL来促进使用SeLeExcReST。我的代码要求用户输入url,然后程序必须在浏览器中打开它,以便url是字符串形式。 非常感谢。

如何从c++;windows中的程序? 我希望我的C++代码打开一个URL。但是所有的线程都使用已经指定的URL来促进使用SeLeExcReST。我的代码要求用户输入url,然后程序必须在浏览器中打开它,以便url是字符串形式。 非常感谢。,c++,url,shellexecute,C++,Url,Shellexecute,诸如此类: std::string myUrl; std::cin >> myUrl; system(std::string("start " + myUrl).c_str()); ?诸如此类: std::string myUrl; std::cin >> myUrl; system(std::string("start " + myUrl).c_str()); ?当然,如果您使用的是Windows,我相信这应该是您的窍门: std::cout<<

诸如此类:

std::string myUrl;
std::cin >> myUrl;
system(std::string("start " + myUrl).c_str());

诸如此类:

std::string myUrl;
std::cin >> myUrl;
system(std::string("start " + myUrl).c_str());

当然,如果您使用的是Windows,我相信这应该是您的窍门:

    std::cout<<"Enter the link: ";
    std::string link;
    std::cin>>link;
    ShellExecute(NULL, "open", link.c_str(), NULL, NULL, SW_SHOWNORMAL);
std::coutlink;
ShellExecute(NULL,“open”,link.c_str(),NULL,NULL,SW_SHOWNORMAL);

如果您使用的是Windows,我相信这应该是您的窍门:

    std::cout<<"Enter the link: ";
    std::string link;
    std::cin>>link;
    ShellExecute(NULL, "open", link.c_str(), NULL, NULL, SW_SHOWNORMAL);
std::coutlink;
ShellExecute(NULL,“open”,link.c_str(),NULL,NULL,SW_SHOWNORMAL);

可能的副本也相关:。你能解释一下ShellExecute的问题吗?您可以将url作为参数传递给函数,以便从用户输入中传递url。可能的重复项也相关:。你能解释一下ShellExecute的问题吗?您可以将url作为参数传递给函数,这样您就可以从用户输入中传递url了。没错!我在使用指针,所以我不得不做一些更改,但这是有效的!谢谢。
system()
打开控制台。有没有办法阻止它那样做?没错!我在使用指针,所以我不得不做一些更改,但这是有效的!谢谢。
system()
打开控制台。有没有办法阻止它这样做?这会导致一个错误,即“HINSTANCE ShellExecuteW(HWND,LPCWSTR,LPCWSTR,LPCWSTR,LPCWSTR,INT)”:无法将参数2从“const char[5]”转换为“LPCWSTR”。它应该是
ShellExecute(NULL,L“open”,link.c_str(),NULL,NULL,SW_SHOWNORMAL)
。事实上,如果您想让它适用于所有字符格式,它应该是
\u T(“打开”)
。除了您还需要将链接作为宽字符串传递之外。最好根据需要使用显式变体
ShellExecuteA
ShellExecuteW
。这样会出现错误,错误为“'HINSTANCE ShellExecuteW(HWND,LPCWSTR,LPCWSTR,LPCWSTR,LPCWSTR,INT)”:无法将参数2从“const char[5]”转换为“LPCWSTR”。它应该是
ShellExecute(NULL,L“open”,link.c_str(),NULL,NULL,SW_SHOWNORMAL)
。事实上,如果您想让它适用于所有字符格式,它应该是
\u T(“打开”)
。除了您还需要将链接作为宽字符串传递之外。最好根据需要使用显式变体
ShellExecuteA
ShellExecuteW