Visit our Sponsor   Visit our Sponsor
delphi3000.com - the free delphi knowledge platform
delphi3000.com - the free delphi knowledge platform
498 Users Online NOW
Have a look at your member-status

connecting people's knowledge


  - Recent ArticlesRSS feed for Recent Articles on delphi3000.com
  - List of All Articles
  - Top Viewed Articles
  - Articles (+Attachem.)
  - Articles Of Interest
  - Categories
  - Top Uploader
  - Search
  - Index

  - My Home
  - Submit an Article
  - My Articles
  - My Personal Data
  - My Bookmarks
  - Activities
  - Login/Logout

  - Sign Up
  - Why Sign Up
  - Newsletter

  - Press
  - Advertise

  - Contact
  - Feedback





Community
Borland
ClubeDelphi
Dr. Bob
UK-BUG
Delphi Meetings
Planeta Delphi



Loremo - the 1.5 liter car coming in 2009




Startblatt.de






Share this article with friendsShare this article with friends
Rate this articleRate this article - to keep the quality of delphi3000.com !
Comment this article or read through previous comments (0)


Sort Order of Internet Explorer FavoritesGo to Daaron Dwyer's websiteFormat this article printer-friendly!Bookmark function is only available for registered users!
Product:
Delphi all versions
Category:
Internet / Web
Skill Level:
Scoring:
Last Update:
03/07/2003
Search Keys:
delphi delphi3000 article borland vcl code-snippet Sort Order Internet Explorer Favorites Registry
Times Scored:
4
Visits:
2382
Uploader: Daaron Dwyer
Company: AngoraSoftware
Reference: N/A
 
Question/Problem/Abstract:
You can easily get the list of favorites from the directory, but how can you emulate the same sort order showing in Internet Explorer?
Answer:



I could not find this information anywhere on the Microsoft site or on Google Groups, so I had to just start digging in the registry and in the binary.

The registry path for favorites is HKey_Current_User\Software\Microsoft\Windows\CurrentVersion\Explorer\MenuOrder\Favorites\, containing the directory structure mirroring the structure in your favorites.

The registry key "order" is a binary containing the visible name, order number, and DOS filename.  The start of the registry binary looks like:

08 00 00 00 02 00 00 00 24 06 00 00 01 00 00 00
16 00 00 00 48 00 00 0D 00 00 00 00 39 00 32 00
98 00 00 00 B1 2C 74 B5 20 00 42 65 6E 20 5A 65
69 67 6C 65 72 27 73 20 44 65 6C 70 68 69 20 50
61 67 65 2E 75 72 6C 00 42 45 4E 5A 45 49 7E 31
2E 55 52 4C 00 00 00 00 05 ...(continues)


Position 16 contains a count of the number of items, 22 in this case. (This is Hex, remember!)
08 00 00 00 02 00 00 00 24 06 00 00 01 00 00 00
16 00 00 00 48 00 00 0D 00 00 00 00 39 00 32 00
98 00 00 00 B1 2C 74 B5 20 00 42 65 6E 20 5A 65
69 67 6C 65 72 27 73 20 44 65 6C 70 68 69 20 50
61 67 65 2E 75 72 6C 00 42 45 4E 5A 45 49 7E 31
2E 55 52 4C 00 00 00 00 05 ...(continues)

Position 17 starts data, with 3 nulls and the count of total data (Hex 48 or 68 in decimal) and 3 more nulls and the order number (position 7, relative to the data start and "D" or 13).
08 00 00 00 02 00 00 00 24 06 00 00 01 00 00 00
16 00 00 00 48 00 00 0D 00 00 00 00 39 00 32 00
98 00 00 00 B1 2C 74 B5 20 00 42 65 6E 20 5A 65
69 67 6C 65 72 27 73 20 44 65 6C 70 68 69 20 50
61 67 65 2E 75 72 6C 00 42 45 4E 5A 45 49 7E 31
2E 55 52 4C 00 00 00 00 05 ...(continues)

Relative position 20 is the count of the name, including the DOS filename.
08 00 00 00 02 00 00 00 24 06 00 00 01 00 00 00
16 00 00 00 48 00 00 0D 00 00 00 00 39 00 32 00
98 00 00 00 B1 2C 74 B5 20 00 42 65 6E 20 5A 65
69 67 6C 65 72 27 73 20 44 65 6C 70 68 69 20 50
61 67 65 2E 75 72 6C 00 42 45 4E 5A 45 49 7E 31
2E 55 52 4C 00 00 00 00 05 ...(continues)


Relative position 25 begins the name, terminated by a null
08 00 00 00 02 00 00 00 24 06 00 00 01 00 00 00
16 00 00 00 48 00 00 0D 00 00 00 00 39 00 32 00
98 00 00 00 B1 2C 74 B5 20 00 42 65 6E 20 5A 65
69 67 6C 65 72 27 73 20 44 65 6C 70 68 69 20 50
61 67 65 2E 75 72 6C 00
42 45 4E 5A 45 49 7E 31
2E 55 52 4C 00 00 00 00 05 ...(continues)

Then a DOS filename, 3 nulls, then a hex value 5 as a terminator.
08 00 00 00 02 00 00 00 24 06 00 00 01 00 00 00
16 00 00 00 48 00 00 0D 00 00 00 00 39 00 32 00
98 00 00 00 B1 2C 74 B5 20 00 42 65 6E 20 5A 65
69 67 6C 65 72 27 73 20 44 65 6C 70 68 69 20 50
61 67 65 2E 75 72 6C 00 42 45 4E 5A 45 49 7E 31
2E 55 52 4C 00 00 00 00 05
...(continues)

And the next record starts after the #5 terminator.

An ugly little chunk of code to pull this data and put it in a TMemo out would be:

const
   REGLEN = 5000;
var
   I,A,B: Integer;
   reg : TRegistry;
   buf : array[0..REGLEN] of char;
   itembuf : array[0..1000] of char;
   lastpos : Integer;
   order : Integer;
   name,dosfile : array[0..200] of char;
   namecount, count : Integer;

begin
     reg := TRegistry.Create;
     reg.RootKey := HKEY_CURRENT_USER;
     reg.OpenKey('Software\Microsoft\Windows\CurrentVersion\Explorer\MenuOrder\Favorites\Delphi',FALSE);
     reg.ReadBinaryData('Order',buf,REGLEN);

     count := ord(buf[16]);
     Memo1.Lines.Add('How Many: '+intToStr(count));

     lastpos := 17;
     for I := 0 to count-1 do    // Iterate
     begin
          for a := lastpos to lastpos+999 do    // Iterate
          begin
               itembuf[a-lastpos] := buf[a];
          end;    // for


          order := ord(itembuf[7]);
          Memo1.Lines.Add('This order '+intToStr(order));

          namecount := ord(itembuf[20]);
          for a := 25 to namecount+25 do    // Iterate
          begin
               name[a-25] := itembuf[a];
               if itembuf[a]=#0 then break;
          end;    // for
          Memo1.Lines.Add('Name '+name);

          for b := a to a+13 do    // Iterate
          begin
               dosfile[b-a-1] := itembuf[b];
          end;    // for
          if dosfile='' then dosfile := name;

          Memo1.Lines.Add('DOS File '+dosfile);

          lastpos := ord(itembuf[3])+lastpos;
     end;    // for
     reg.free;





Please rate this article!
Skill level:
BeginnerExpert

Useful:
No!Very!

Overall rating:
PoorExcellent



Comments to this article
Write a new comment













 
Sign up to consume product discounts for Bronze memberships !

read more


  Visit our Sponsor

 

  Community Ad of
Hans Gulö
 
   














 







     
  Copyright © 2000 - 2007 delphi3000.com - All rights reserved. Terms of use. || Privacy
delphi3000.com is a service by bluestep.com IT-Services GmbH (Vienna)