(******************************************************************************)
(* Enumerate - Returns a list of extensions currently associated with *)
(* currently identified application. *)
(******************************************************************************)
function TMILAssociate.Enumerate : TStringList;
var
KeyList,
ResultList : TStringList;
iCount,
jCount : Integer;
WorkStr,
WorkStr2 : String;
begin
KeyList := TStringList.Create;
ResultList := TStringList.Create;
shellReg := TRegistry.Create;
shellReg.RootKey := HKEY_CLASSES_ROOT;
shellReg.OpenKey('', False);
shellReg.GetKeyNames(KeyList);
for iCount := 0 to KeyList.Count - 1 do
begin
if Copy(KeyList.Strings[iCount], 1, 1) <> '.' then
begin
shellReg.CloseKey;
shellReg.OpenKey(KeyList.Strings[iCount] + '/Shell/Open/Command', False);
WorkStr := shellReg.ReadString('');
if Pos(ExtractFileName(FShell), WorkStr) > 0 then
begin
for jCount := 0 to KeyList.Count - 1 do
begin
if Copy(KeyList.Strings[jCount], 1, 1) = '.' then
begin
shellReg.CloseKey;
shellReg.OpenKey(KeyList.Strings[jCount], False);
WorkStr2 := shellReg.ReadString('');
if WorkStr2 = KeyList.Strings[iCount] then
ResultList.Add(UpperCase(KeyList.Strings[jCount]));
end;
end;
end;
end;
end;
KeyList.Clear;
KeyList.Free;
shellReg.CloseKey;
shellReg.Free;
Result := ResultList;
end;