macosdelphilaunch-services

Delphi Macapi.CoreServices is missing the LaunchServices


I am trying to use the LSCopyAllHandlersForURLScheme function to enumerate through the installed web browsers under Mac OS X, in my way, I was checking the Macapi.CoreServices file included in Delphi RTL, and I found that not all the include files actually exist, they appear like comments instead of an $I include directive, am I missing something? Here is the code

unit Macapi.CoreServices;

{$WEAKPACKAGEUNIT}

interface

{$I OSTypes.inc}
{$I MacTypes.inc}
{$I TextCommon.inc}
{$I Files.inc}
{$I DispatchSemaphores.inc}
{$I MacErrors.inc}
{$IFNDEF IOS}
{$I Multiprocessing.inc}
{$I DriverServices.inc}
{$I Gestalt.inc}
{$ENDIF !IOS}
{ $I OSServices.inc}
{ $I SFNetwork.inc}
{ $I LaunchServices.inc}
{ $I SearchKit.inc}
{ $I Metadata.inc}
{ $I DictionaryServices.inc}
{ $I AE.inc}

const
  CoreServicesLib = '/System/Library/Frameworks/CoreServices.framework/CoreServices';
  {$EXTERNALSYM CoreServicesLib}
  CarbonCoreLib = '/System/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework/CarbonCore';
  {$EXTERNALSYM CarbonCoreLib}

implementation

{$IF NOT DECLARED(_PU)}
const
  {$IFDEF UNDERSCOREIMPORTNAME}
  _PU = '_';
  {$ELSE}
  _PU = '';
  {$ENDIF}
{$ENDIF}

{$I MacTypesImpl.inc}
{ $I TextCommonImpl.inc}
{$I FilesImpl.inc}
{$I DispatchSemaphoresImpl.inc}
{$IFNDEF IOS}
{$I MultiprocessingImpl.inc}
{$I DriverServicesImpl.inc}
{$I GestaltImpl.inc}
{$ENDIF !IOS}
{ $I OSServicesImpl.inc}
{ $I SFNetworkImpl.inc}
{ $I LaunchServicesImpl.inc}
{ $I SearchKitImpl.inc}
{ $I MetadataImpl.inc}
{ $I DictionaryServicesImpl.inc}
{ $I AEImpl.inc}

end.

Solution

  • I imported the function myself for now, here is how to do it (really easy):

    const launchServicesLib = '/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/LaunchServices';
    function LSCopyAllHandlersForURLScheme(inURLScheme: CFStringRef) : CFArrayRef; cdecl; external launchServicesLib name '_LSCopyAllHandlersForURLScheme';
    

    I don't know why Embarcadero didn't implement the LaunchServices!

    Thanks,