gpt4 book ai didi

c - 我想通过 shellexecute() 通过变量打开网站,方法是在 c 中为变量分配网址

转载 作者:行者123 更新时间:2023-11-30 17:15:22 25 4
gpt4 key购买 nike

我想通过c中的shellexecute()打开一个网页。如果我之前提供了网址,shellexecute() 工作正常,但如果我想更改该网址,我该怎么办?

这里是例子:

ShellExecute(NULL, "open", "rundll32.exe", "url.dll,FileProtocolHandler <a href="http://www.google.com" rel="noreferrer noopener nofollow">http://www.google.com</a>",NULL,SW_SHOWNORMAL);

但是如果我想打开 http://facebook.com 该怎么办? ?有没有办法动态分配婚礼地址,例如在 shellexecute() 或任何其他方法中包含变量?

那么最后有没有办法用我们要分配的变量替换 shellexecute() 中的实际网址?

提前谢谢您!

最佳答案

您无法通过更新变量来更改 URL,但只需使用新 URL 再次调用 ShellExecute 即可做到这一点。来自微软的documentation :

Call the ShellExecute API and pass it a URL. That is the easiest wayfor you to start the default Web browser from your application. If thedefault Web browser currently runs, ShellExecute tells the instancethat runs to go to your Uniform Resource Locator (URL). If it is notrunning, ShellExecute starts the application and then browses to yourURL.

这个措辞有点奇怪,但它说当你调用 ShellExecute() 时,如果默认浏览器没有运行,它将启动默认浏览器并将其发送到你的 URL,但如果默认浏览器已经运行,它只会重定向它到您传递的 URL。

关于c - 我想通过 shellexecute() 通过变量打开网站,方法是在 c 中为变量分配网址,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30017164/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com