Do a search in the Registry for your extension in HKEY_CLASSES_ROOT, after finding it get its default value and then do a new search for it. Now, read the Shell\Open\Command key's default value.
~~~~~~~~~~~~~~~~~~~~~~~~~
{
Usage: //find and start
var
sExe:string;
begin
sEXE:=GetExeByExtension('.htm') ;
if (sEXE <> '') and FileExists(sEXE) then
ShellExecute(Handle,'OPEN', PChar(sEXE), nil, nil, SW_SHOWNORMAL) ;
}
Uses Registry;
function GetExeByExtension(sExt : string) : string;
var
sExtDesc:string;
begin
with TRegistry.Create do
begin
try
RootKey:=HKEY_CLASSES_ROOT;
if OpenKeyReadOnly(sExt) then
begin
sExtDesc:=ReadString('') ;
CloseKey;
end;
if sExtDesc <>'' then
begin
if OpenKeyReadOnly(sExtDesc + '\Shell\Open\Command') then
begin
Result:= ReadString('') ;
end
end;
finally
Free;
end;
end;
if Result <> '' then
begin
if Result[1] = '"' then
begin
Result:=Copy(Result,2,-1 + Pos('"',Copy(Result,2,MaxINt))) ;
end
end;
end;
~~~~~~~~~~~~~~~~~~~~~~~~~
Delphi tips navigator:
» Using an object with no reference variable
« Disable LogOff, TaskManager and ShutDown on Win NT systems (2000/XP)
