Innnards: Windows XP Service Pack 2 breaks form submissions in ShellExecute URLs

As the author of the WWW FAQ, I regularly answer questions about the workings of the Web. If a question is frequently asked, I simply add an article to the FAQ. But sometimes a question is more detailed, more in-depth— not really a FAQ, but still of interest to others. You'll find those questions, with my answers, here in Innards along with commentary on other web-technology-related topics.

2004-09-16

Anyone who writes Windows applications that launch URLs by calling the ShellExecute API function will be interested to hear that, beginning with the recently released Windows XP Service Pack 2, it is no longer possible to include a query string in the URL. That is, the following call won't do what you expect:

ShellExecute(hwnd,
	"open",
	"http://somewhere.com/something.php?name=jane&password=isthequeen",
	0,
	0,
	SW_SHOWNORMAL);
In earlier versions of Windows, this call will open the specified URL in the user's preferred web browser application, complete with the query string. In Windows XP Service Pack 2, the ? and everything after it is deleted.

You can work around this by passing your arguments as part of the path. For instance:

http://somewhere.com/something.php/user=jane/password=isthequeen
Apache, and most other web servers with the rumored exception of Microsoft Internet Information Server, are smart enough to recognize that something.php should still be run in this case and will place the rest of the path in the $path_info variable in your PHP script. You can then split this string apart and parse the individual arguments. I have done something similar to maintain support for hassle-free logins to the internal web server of Wusage 8.0.

Follow us on Twitter | Contact Us

Copyright 1994-2012 Boutell.Com, Inc. All Rights Reserved.