{
关键字=获得文件扩展名缺省程序
采集软件=MKM - 我的知识管理
采集日期=2023-11-23 15:06:59
数字签名=500C14DFAB7D596F1FE83440988D17EF
}
uses
Registry, shlobj, Windows;
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;