Martin Heller
Contributing Writer

Detecting IE7 Protected Mode

analysis
Apr 6, 20072 mins

I have been wondering if there's a way that a Web page can tell if it's running in IE7 Protected Mode on Windows Vista. It turns out that yes, there is, but it's not as simple as I'd like. My hope was that there would be flags that a page could check from JavaScript: ideally, a flag that says either "I'm in Protected Mode" "I've got normal privilege", or "I'm running as Administrator". I did

I have been wondering if there’s a way that a Web page can tell if it’s running in IE7 Protected Mode on Windows Vista. It turns out that yes, there is, but it’s not as simple as I’d like.

My hope was that there would be flags that a page could check from JavaScript: ideally, a flag that says either

  • “I’m in Protected Mode”
  • “I’ve got normal privilege”, or
  • “I’m running as Administrator”.

I didn’t find anything like that, even though IE 7 displays the Protected Mode status to the user. What I did find is an IE API, the IEIsProtectedModeProcess Function, which can tell a caller whether or not IE is a Protected Mode process by setting a BOOL parameter TRUE or FALSE.

It’s in ieframe.dll, but only for IE 7 or later. And it is only supported in Microsoft Windows Vista or later. If you call it from earlier versions of Microsoft Windows, this function returns E_NOTIMPL as its HRESULT.

So, if I have this right, I could call this function from an ActiveX control or an IE toolbar, after first dynamically loading it from ieframe.dll. If I called it from an ActiveX control, then the ActiveX control could in turn expose a COM property to JavaScript. I know how to do that.

This seems like scratching your left ear with your right hand, doesn’t it? But it should work.

Now I have to figure out how to safely tell if the IE process is running as Administrator. Somehow, I don’t think trying to reformat the system drive would be an ideal test.

Martin Heller

Martin Heller is a contributing writer at InfoWorld. Formerly a web and Windows programming consultant, he developed databases, software, and websites from his office in Andover, Massachusetts, from 1986 to 2010. From 2010 to August of 2012, Martin was vice president of technology and education at Alpha Software. From March 2013 to January 2014, he was chairman of Tubifi, maker of a cloud-based video editor, having previously served as CEO.

Martin is the author or co-author of nearly a dozen PC software packages and half a dozen Web applications. He is also the author of several books on Windows programming. As a consultant, Martin has worked with companies of all sizes to design, develop, improve, and/or debug Windows, web, and database applications, and has performed strategic business consulting for high-tech corporations ranging from tiny to Fortune 100 and from local to multinational.

Martin’s specialties include programming languages C++, Python, C#, JavaScript, and SQL, and databases PostgreSQL, MySQL, Microsoft SQL Server, Oracle Database, Google Cloud Spanner, CockroachDB, MongoDB, Cassandra, and Couchbase. He writes about software development, data management, analytics, AI, and machine learning, contributing technology analyses, explainers, how-to articles, and hands-on reviews of software development tools, data platforms, AI models, machine learning libraries, and much more.

More from this author