Archive for the ‘Internet Explorer Plugin’ Category

Internet Explorer Plugins and Vista

October 20, 2008

So I’ve recently got a new machine that came pre installed with Windows Vista. ¬†And now I’ve got the fun task of trying to make everything work again with my plugin ūüôā


There are a number of places where I’ve found some good info on this, which I will enumerate here for your and my benefit.¬†– A Developer’s Survival Guide to IE Protected Mode РInside Windows Vista User Account Control¬†–¬†Understanding and Working in Protected Mode Internet Explorer¬†–¬†Protected Mode in Vista IE7

A couple of key things if you’re relying on the compatibility shims: (described in a little more detail in the 4th link)
Registry Accesses (to HKCU software) are moved to
HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\InternetRegistry\REGISTRY\USER\[User security identifier – SID]\Software\[my key]
File accesses (to acceptable locations) are moved to 
 %userprofile%\AppData\Local\Microsoft\Windows\Temporary Internet Files\Virtualized\{system drive letter}\Users\{username}
I hope to update more this as I dive further into updating my plugin and making it work in both XP and Vista.

Creating a cookie within a C# plugin in Internet Explorer

June 5, 2007

I had the need to create a cookie from within my IE plug-in. I create a session cookie when the browser is loaded so that when a user visits my site, I know what version of the plug-in is installed. There appears to be no direct C# API to do this (based on a few google searches). I did find from these searches that there is a method called InternetSetCookie in wininet.dll

For those who don’t regularly have to jump out into the COM world, the code to do this can be a bit of a pain to track down, so here’s the C# import of the method as well as a nice wrapper that will throw an exception if the call is not successful.

        static extern bool InternetSetCookie(string url, string cookieName, string cookieData);

        public static void SetCookie(string siteUrl, string cookieName, string cookieData)
            if (!InternetSetCookie(siteUrl, cookieName, cookieData))
                throw new Exception("Exception setting cookie: Win32 Error code="+Marshal.GetLastWin32Error());

Note that siteUrl must be in the form of “” and cannot include a port specification.

For reference the MSDN entry for InternetSetCookie is here.

More details on how to specify the expiration dates of the cookies is here.

And in case you want even more info on cookies in IE, this page describes each of the possible cookie fields in detail.