Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

Internet Explorer Favorites, deconstructed

, 24 Dec 2007
Description of the binary format used to store internet explorer favorites, includes Favorites-to-XBEL example project.
favorites2xbel.zip
Favorites2XBEL
Favorites2XBEL.suo
Favorites2XBEL
bin
Debug
xbel2xhtml.xsl
Release
xbel2xhtml.xsl
obj
Properties
xbel2xhtml.xsl
favorites2xbelvs2005.zip
Favorites2XBEL.suo
xbel2xhtml.xsl
xbel2xhtml.xsl
xbel2xhtml.xsl
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;

namespace CodeProject.IEFavDecon
{
    /// <summary>
    /// Interop wrapper for the legacy "PrivateProfileString" API.
    /// </summary>
    public class IniFile
    {
        [DllImport("KERNEL32.DLL", EntryPoint = "WritePrivateProfileStringA", CharSet = CharSet.Ansi, SetLastError = true)]
        private static extern int WritePrivateProfileString(string section, string key, string value, string filename);

        [DllImport("KERNEL32.DLL", EntryPoint = "GetPrivateProfileStringA", CharSet = CharSet.Ansi, SetLastError=true)]
        private static extern int GetPrivateProfileString(string section, string key, string defaultValue, StringBuilder returnString, int returnSize, string filename);

        private string filename;

        public IniFile(string filename)
        {
            this.filename = filename;
        }

        public string GetValue(string section,string key,string defaultValue)
        {
			StringBuilder sb = new StringBuilder(32768);
            GetPrivateProfileString(section, key, defaultValue, sb, sb.Capacity, filename);
			return sb.ToString();
        }

        public void WriteValue(string section, string key, string value)
        {
            if (WritePrivateProfileString(section, key, value, filename) == 0)
            {
                throw new Exception("WritePrivateProfileString failed: code " + Marshal.GetLastWin32Error().ToString());
            }
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

jpmik
Architect
Netherlands Netherlands
No Biography provided

| Advertise | Privacy | Mobile
Web03 | 2.8.140721.1 | Last Updated 24 Dec 2007
Article Copyright 2007 by jpmik
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid