Best way to load a webpage from C++

Started by
1 comment, last by Frank Force 15 years, 3 months ago
I am working on a windows screensaver in a multi-threaded environment. Trying to load a webpage when someone clicks on a button. Was using the code... ShellExecute(NULL, L"open", L"http://www.frankforce.com", NULL, NULL, SW_SHOWNORMAL); Worked ok except there was a bug. I use zonealarm so when the firewall popped up about this program trying to access the internet I decided to try blocking it's access. This caused the thread to never exit and the program to stay running in background even though you could still set the settings and click the ok button. Eventually multiple copies would be running in background until manually shut down. Checked in debugger and saw that the ShellExecute function never exits in this case. Read up on stuff. Now using new improved call to open webpage. SHELLEXECUTEINFOW shellInfo; ZeroMemory (&shellInfo, sizeof (SHELLEXECUTEINFO)); shellInfo.cbSize = sizeof(shellInfo); shellInfo.fMask = SEE_MASK_ASYNCOK; shellInfo.lpVerb = L"open"; shellInfo.lpFile = L"http://www.frankforce.com"; shellInfo.nShow = SW_SHOWNORMAL; ShellExecuteEx(&shellInfo); The key difference is the SEE_MASK_ASYNCOK which kicks control right back after the call. Seems to work well now. But I noticed a glitch maybe a security hole in zone alarm. If i disallow my program's access and then just rapidly click on the button that tries to load the webpage eventually it will load the webpage even though zonalarm should prevent it. What's going on here? - Frank Force
Advertisement
Here's my guess (take with some salt):

ZoneAlarm works on a per-process basis. Any process that tries to create a connection is checked to see if it is allowed. However, what you are doing is creating a new process, this time for the web browser (or whatever your default URL handler is). So ZoneAlarm sees two processes: yours, which is not actually connecting to the Internet, and the browser, which is connecting. Unless the browser is blocked by ZoneAlarm, it should work just fine.

Wielder of the Sacred Wands
[Work - ArenaNet] [Epoch Language] [Scribblings]

Was using Firefox as default browser. Just tested with Chrome. With chrome I don't get any firewall popup with my code. I think is is Firefox that has a feature of kicking it over to zonealarm if another process tries to open a webpage. So basically I think it's just Firefox that is being glitchy.

This topic is closed to new replies.

Advertisement