ShellExecute打开默认浏览器 [英] ShellExecute to open default browser

查看:675
本文介绍了ShellExecute打开默认浏览器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我正在尝试设置ShellExecute,以便当我单击任务栏图标时,它将在默认浏览器上打开一个新页面.

我有以下代码:

Hi,

I''m trying to set up a ShellExecute so that when I click on a tray icon, it opens up a new page on the default browser.

I have the following code :

HINSTANCE hInst = ShellExecute(0, "open", server_url,NULL, NULL ,SW_SHOWNORMAL);


其中server_url是我要访问的网站的URL.

问题是,如果在打开浏览器后执行此操作,则可以正常打开,没有问题.如果我尝试在尚未打开浏览器的情况下执行此操作,则会打开浏览器,但顶部栏上带有后退/下一步按钮以及最小缩放,最大化和关闭按钮.其他人有这个问题吗?

谢谢!


with server_url being the url of the website that I wish to go to.

Problem is, if I do it when my browser is already open, it opens up fine with no problem. If I try to do it when my browser is not already open, it opens up but the top bar with the back/next button and the minizime, maximize and close buttons are not there. Anyone else had this problem?

Thanks!

推荐答案

似乎我找到了可以解决您问题的东西:

Seems that I have found something that might fix your problem:

LONG r = ShellExecute(NULL, "open", "http://www.microsoft.com", NULL, NULL, SW_SHOWNORMAL);



该问题似乎在于您的参数为SW_SHOWDEFAULT,而我在 http://support.microsoft.com上找到的MSDN示例/kb/224816/zh-CN [^ ]使用SW_SHOWNORMAL.
您可以在MSDN上找到所有适用参数的说明: http://msdn.microsoft.com/en-us/library/bb762153(v=vs.85).aspx [



The probelm seems to lie with your parameter being SW_SHOWDEFAULT whereas the MSDN sample I found at http://support.microsoft.com/kb/224816/en-us[^] uses SW_SHOWNORMAL.
You can find an explanation for all the applicable parameters on MSDN: http://msdn.microsoft.com/en-us/library/bb762153(v=vs.85).aspx[^]. This site goes on to explain:

SW_SHOWDEFAULT (10)
Sets the show state based on the SW_ flag specified in the STARTUPINFO structure passed to the CreateProcess function by the program that started the application. An application should call ShowWindow with this flag to set the initial show state of its main window.
SW_SHOWNORMAL (1)
Activates and displays a window. If the window is minimized or maximized, Windows restores it to its original size and position. An application should specify this flag when displaying the window for the first time.

I''m not quite sure if that really solves your problem, but I think you should try your code and substitute SW_SHOWDEFAULT with SW_SHOWNORMAL.

Best regards,

-MRB


这篇关于ShellExecute打开默认浏览器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆