diff --git a/windows/src/developer/TIKE/main/KeymanDeveloperUtils.pas b/windows/src/developer/TIKE/main/KeymanDeveloperUtils.pas index 5cc891f958..6a3eaacc43 100644 --- a/windows/src/developer/TIKE/main/KeymanDeveloperUtils.pas +++ b/windows/src/developer/TIKE/main/KeymanDeveloperUtils.pas @@ -340,7 +340,12 @@ end; function IsKeymanDesktopInstalled: Boolean; begin - Result := FileExists(TKeymanPaths.KeymanDesktopInstallPath(TKeymanPaths.S_KMShell)); + try + Result := FileExists(TKeymanPaths.KeymanDesktopInstallPath(TKeymanPaths.S_KMShell)); + except + on E:EKeymanPath do + Result := False; + end; end; procedure InstallPackage(const nm: string; FCanInstallUnreg: Boolean); @@ -356,7 +361,16 @@ begin Exit; end; - kmshell := TKeymanPaths.KeymanDesktopInstallPath(TKeymanPaths.S_KMShell); + try + kmshell := TKeymanPaths.KeymanDesktopInstallPath(TKeymanPaths.S_KMShell); + except + on E:EKeymanPath do + begin + ShowMessage('Keyman Desktop is not installed. You must install Keyman Desktop to install this keyboard.'); + Exit; + end; + end; + if TUtilExecute.WaitForProcess('"'+kmshell+'" -i "'+nm+'"', ExtractFilePath(nm)) = False then // I3475 ShowMessage('Failed to install package: '+errmsg); @@ -615,7 +629,12 @@ end; function GetKMShellPath(var ps: string): Boolean; // I3655 begin - ps := TKeymanPaths.KeymanDesktopInstallPath(TKeymanPaths.S_KMShell); + try + ps := TKeymanPaths.KeymanDesktopInstallPath(TKeymanPaths.S_KMShell); + except + on E:EKeymanPath do + Exit(False); + end; Result := FileExists(ps); end; diff --git a/windows/src/global/delphi/general/KeymanPaths.pas b/windows/src/global/delphi/general/KeymanPaths.pas index 5ec2df5cba..5e92b59533 100644 --- a/windows/src/global/delphi/general/KeymanPaths.pas +++ b/windows/src/global/delphi/general/KeymanPaths.pas @@ -2,7 +2,12 @@ unit KeymanPaths; interface +uses + System.SysUtils; + type + EKeymanPath = class(Exception); + TKeymanPaths = class public const S_KMShell = 'kmshell.exe'; @@ -28,7 +33,6 @@ uses Winapi.Windows, Winapi.ActiveX, Winapi.ShlObj, - System.SysUtils, System.Win.Registry, DebugPaths, @@ -90,7 +94,7 @@ begin Result := GetDebugPath('KeymanDesktop', Result); if Result = '' then - raise Exception.Create('Unable to find the Keyman Desktop directory. You should reinstall the product.'); + raise EKeymanPath.Create('Unable to find the Keyman Desktop directory. You should reinstall the product.'); Result := IncludeTrailingPathDelimiter(Result) + filename; end; @@ -114,7 +118,7 @@ begin Result := GetDebugPath('KeymanEngine', Result); if Result = '' then - raise Exception.Create('Unable to find the Keyman Engine directory. You should reinstall the product.'); + raise EKeymanPath.Create('Unable to find the Keyman Engine directory. You should reinstall the product.'); Result := IncludeTrailingPathDelimiter(Result) + filename; end; @@ -147,7 +151,7 @@ begin Result := GetDebugPath('Keyboards', Result, True); if Result = '' then - raise Exception.Create('Unable to find the Keyboards directory. You should reinstall the product.'); + raise EKeymanPath.Create('Unable to find the Keyboards directory. You should reinstall the product.'); Result := Result + Filename; end;