Author: Khalid A
Creating Custom Explorer Bars , Band Object
Answer:
1 function AddExplorerBar(BarTitle, Url: string; BarSize: Int64; Horizontal:
2 Boolean): string;
3 const
4 EXPLORERBAR_ID = '{4D5C8C2A-D075-11d0-B416-00C04FB90376}';
5 VERTICAL_BAR = '{00021493-0000-0000-C000-000000000046}';
6 HORIZONTAL_BAR = '{00021494-0000-0000-C000-000000000046}';
7 var
8 GUID: TGUID;
9 SysDir, ID: string;
10 Reg: TRegistry;
11 begin
12 CreateGuid(GUID);
13 ID := GuidToString(GUID);
14 Reg := TRegistry.Create;
15 with Reg do
16 try
17 RootKey := HKEY_CLASSES_ROOT;
18 OpenKey('\CLSID\' + ID, True);
19 WriteString('', 'BarTitle');
20 CloseKey;
21 CreateKey('\CLSID\' + ID + '\Implemented Categories');
22 if HORIZONTAL then
23 CreateKey('\CLSID\' + ID + '\Implemented Categories\' +
24 HORIZONTAL_BAR)
25 else
26 CreateKey('\CLSID\' + ID + '\Implemented Categories\' +
27 VERTICAL_BAR);
28 SetLength(SysDir, 255);
29 GetSysDirectory(PChar(SysDir), 255);
30 SysDir := PChar(SysDir) + '\SHDOCVW.DLL';
31 OpenKey('\CLSID\' + ID + '\InProcServer32', True);
32 Writestring('', SysDir);
33 WriteString('Threadingmodel', 'Apartment');
34 CloseKey;
35 OpenKey('\CLSID\' + ID + '\Instance', True);
36 WriteString('CLSID', EXPLORERBAR_ID);
37 CloseKey;
38 OpenKey('\CLSID\' + ID + '\Instance\InitPropertyBag', True);
39 WriteString('Url', URL);
40 CloseKey;
41 RootKey := HKEY_LOCAL_MACHINE;
42 OpenKey('Software\Microsoft\Internet Explorer\Explorer Bars\'
43 + ID, True);
44 WriteBinaryData('BarSize', BarSize, SizeOf(BarSize));
45 CloseKey;
46 OpenKey('\Software\IE5Tools\Explorer Bars\', True);
47 WriteString(BarTitle, ID);
48 CloseKey;
49 OpenKey('\Software\Microsoft\Internet Explorer\Toolbar', True)
50 WriteString(ID, '');
51 CloseKey;
52 finally
53 Free;
54 end;
55 result := ID;
56 end;
|