MBS Plugin Documentation

Search:

Statistics   -   FAQ   -   Plugin Parts (All, Dependencies)   -   Class hierarchie

New in Version 7.0 7.1 7.2 7.3 7.4 7.5 7.6 7.7 7.8 8.0 8.1 8.2 8.3 8.4 8.5 8.6 8.7 9.0

The list of the   themes,   classes,   controls,   modules,   global methods by category,   global methods by name,   screenshots,   licenses   and   examples.

Platforms to show: All Mac Windows Linux Cross-Platform

LaunchServicesAllHandlersForURLSchemeMBS(URLScheme as string) as LaunchServicesStringListMBS
global method, Launch Services, MBS MacOSX Plugin (LaunchServicesCF), Console safe, Plugin version: 6.1, Mac OS X: Works, Windows: Does nothing, Linux x86: Does nothing, Feedback.

Function: Returns an array of application bundle identifiers for applications capable of handling the specified URL scheme.
Example:
dim l as LaunchServicesStringListMBS
dim s(-1) as string
dim i,c as integer

l=LaunchServicesAllHandlersForURLSchemeMBS("http")
if l<>nil then
c=l.Count-1
for i=0 to c
s.Append l.Item(i)
next

MsgBox Join(s,", ")
end if

Notes:
URL handling capability is determined according to the kCFBundleURLTypes listed in an application's Info.plist).
Returns nil if no handlers are available.

Example output from the code above:
org.videolan.vlc, com.RealNetworks.RealPlayer, org.mozilla.firefox, com.apple.safari, de.icab.iCab, com.microsoft.explorer

Requires Mac OS X 10.4 to work correct. Returns always nil on older systems.
LaunchServicesAllRoleHandlersForContentTypeMBS(ContentType as string, role as integer) as LaunchServicesStringListMBS
global method, Launch Services, MBS MacOSX Plugin (LaunchServicesCF), Console safe, Plugin version: 6.0, Mac OS X: Works, Windows: Does nothing, Linux x86: Does nothing, Feedback.

Function: Returns an array of application bundle identifiers for applications capable of handling the specified content type (UTI) with the specified role(s).
Example:
dim l as LaunchServicesStringListMBS
dim s(-1) as string
dim i,c as integer

const kLSRolesAll=-1

l=LaunchServicesAllRoleHandlersForContentTypeMBS("com.adobe.pdf",kLSRolesAll)
if l<>nil then
c=l.Count-1
for i=0 to c
s.Append l.Item(i)
next

MsgBox Join(s,", ")
end if

Notes:
Application content handling capabilities are determined according to the kCFBundleDocumentTypes listed in an application's Info.plist). For any role, specify kLSRolesAll.
Returns nil if no handlers are available.
Requires Mac OS X 10.4.

Constants you can use for the role parameter:
kLSRolesNone = 1no claim is made about support for this type/scheme
kLSRolesViewer= 2claim to be able to view this type/scheme
kLSRolesEditor= 4claim to be able to edit this type/scheme
kLSRolesAll = -1claim to do it all

Example output for code above is:
com.adobe.Reader, com.apple.preview, com.adobe.acrobat.reader, com.apple.MDIimporter.PDF
LaunchServicesApplicationForInfoMBS(type as string, creator as string, extension as string, role as integer) as folderitem
global method, Launch Services, MBS MacOSX Plugin (LaunchServices), Console safe, Plugin version: 3.2, Mac OS X: Works, Windows: Does nothing, Linux x86: Does nothing, Feedback.

Function: Return the application used to open items with particular data.
Notes:
Consults the binding tables to return the application that would be used to open items with type, creator, and/or extension as provided if they were double-clicked in the Finder. This application will be the default for items like this if one has been set. If no application is known to LaunchServices suitable for opening such items, nil (kLSApplicationNotFoundErr) will be returned. Not all three input parameters can be "" at the same time nor can both output parameters be "" at the same time.

Constants you can use for the role parameter:
kLSRolesNone = 1no claim is made about support for this type/scheme
kLSRolesViewer= 2claim to be able to view this type/scheme
kLSRolesEditor= 4claim to be able to edit this type/scheme
kLSRolesAll = -1claim to do it all
LaunchServicesApplicationForItemMBS(file as folderitem, role as integer) as folderitem
global method, Launch Services, MBS MacOSX Plugin (LaunchServices), Console safe, Plugin version: 3.2, Mac OS X: Works, Windows: Does nothing, Linux x86: Does nothing, Feedback.

Function: Return the application used to open an item.
Example:
dim file,appf as FolderItem

file=DesktopFolder.Child("d.rb") // some Realbasic file
appf=LaunchServicesApplicationForItemMBS(file, 0)

MsgBox appf.AbsolutePath

Notes:
Consults the binding tables to return the application that would be used to open the folderitem if it were double-clicked in the Finder. This application will be the user-specified override if appropriate or the default otherwise. If no application is known to LaunchServices suitable for opening this item, nil (kLSApplicationNotFoundErr) will be returned.

Constants you can use for the role parameter:
kLSRolesNone = 1no claim is made about support for this type/scheme
kLSRolesViewer= 2claim to be able to view this type/scheme
kLSRolesEditor= 4claim to be able to edit this type/scheme
kLSRolesAll = -1claim to do it all
LaunchServicesCanApplicationAcceptItemMBS(item as folderitem, targetapp as folderitem, role as integer, flags as integer) as boolean
global method, Launch Services, MBS MacOSX Plugin (LaunchServices), Console safe, Plugin version: 3.2, Mac OS X: Works, Windows: Does nothing, Linux x86: Does nothing, Feedback.

Function: Determine whether an item can accept another item.
Notes:
Returns whether TargetApp can accept this folderitem as in a drag and drop operation. If role is other than kLSRolesAll then make sure TargetApp claims to fulfill the requested role.

Constants you can use for the role parameter:
kLSRolesNone = 1no claim is made about support for this type/scheme
kLSRolesViewer= 2claim to be able to view this type/scheme
kLSRolesEditor= 4claim to be able to edit this type/scheme
kLSRolesAll = -1claim to do it all

Values for the flags:
kLSAcceptDefault = 1
kLSAcceptAllowLoginUI= 2show UI to log in if necessary
LaunchServicesDefaultHandlerForURLSchemeMBS(URLScheme as string) as string
global method, Launch Services, MBS MacOSX Plugin (LaunchServicesCF), Console safe, Plugin version: 6.1, Mac OS X: Works, Windows: Does nothing, Linux x86: Does nothing, Feedback.

Function: Returns the bundle identifier of the default handler for the specified URL scheme.
Example:
MsgBox LaunchServicesDefaultHandlerForURLSchemeMBS("http") // shows here: com.apple.safari

Notes:
Returns "" if no handler is available.
Requires Mac OS X 10.4 to work correct. Returns always "" on older systems.
LaunchServicesDefaultRoleHandlerForContentTypeMBS(ContentType as string, role as integer) as string
global method, Launch Services, MBS MacOSX Plugin (LaunchServicesCF), Console safe, Plugin version: 6.0, Mac OS X: Works, Windows: Does nothing, Linux x86: Does nothing, Feedback.

Function: Returns the application bundle identifier of the default handler for the specified content type (UTI), in the specified role(s).
Example:
const type="com.adobe.pdf"
msgbox LaunchServicesDefaultRoleHandlerForContentTypeMBS(type,-1)

Notes:
For any role, specify kLSRolesAll. Returns "" if no handler is available.
Requires Mac OS X 10.4.

Constants you can use for the role parameter:
kLSRolesNone = 1no claim is made about support for this type/scheme
kLSRolesViewer= 2claim to be able to view this type/scheme
kLSRolesEditor= 4claim to be able to edit this type/scheme
kLSRolesAll = -1claim to do it all
LaunchServicesDisplayNameForCFURLMBS(cfurlhandle as integer) as string
global method, Launch Services, MBS MacOSX Plugin (LaunchServices), Console safe, Plugin version: 3.2, Mac OS X: Works, Windows: Does nothing, Linux x86: Does nothing, Feedback.

Function: Get the display name for an url handle.
Notes:
Return a copy of the display name for an url handle. Takes into consideration whether this item has a hidden extension or not.

Cfurlhandle should be the non 0 value from a CFURL object handle property.
LaunchServicesFindApplicationForInfoMBS(creator as string, bundleID as string, name as string) as folderitem
global method, Launch Services, MBS MacOSX Plugin (LaunchServices), Console safe, Plugin version: 3.2, Mac OS X: Works, Windows: Does nothing, Linux x86: Does nothing, Feedback.

Function: Locate a specific application.
Example:
MsgBox LaunchServicesFindApplicationForInfoMBS("","R*ch","txt",-1).name
MsgBox LaunchServicesFindApplicationForInfoMBS("TEXT","","",-1).name
MsgBox LaunchServicesFindApplicationForInfoMBS("","","txt",-1).name

Notes:
Returns the application with the corresponding input information. The registry of applications is consulted first in order of bundleID, then creator, then name. All comparisons are case insensitive and 'ties' are decided first by version, then by native vs. Classic.

Parameters can be "". The name of the application must be the name with the extension.

Some examples using this method:

LaunchServicesItemInfoForCFURLMBS(cfurlhandle as integer, WhichInfo as integer) as LaunchServicesItemInfoMBS
global method, Launch Services, MBS MacOSX Plugin (LaunchServices), Console safe, Plugin version: 3.2, Mac OS X: Works, Windows: Does nothing, Linux x86: Does nothing, Feedback.

Function: Return information about an item.
Notes:
Returns as much or as little information as requested about the url. Some information is available in a thread-safe manner, some is not.

Cfurlhandle should be the non 0 value from a CFURL object handle property.

Possible values you can combine for the WhichInfo parameter:
kLSRequestExtension = &h01Requests the item’s filename extension.
kLSRequestTypeCreator = &h02Requests the item’s file type and creator signature.
kLSRequestBasicFlagsOnly = &h04Requests all item-information flags that are not application-specific: that is, all except IsNativeApp, IsClassicApp, AppPrefersNative, AppPrefersClassic and AppIsScriptable.
kLSRequestAppTypeFlags = &h08Requests all application-specific item-information flags: that is, IsNativeApp, IsClassicApp, AppPrefersNative, AppPrefersClassic and AppIsScriptable.
kLSRequestAllFlags = &h10Requests all item-information flags.
kLSRequestIconAndKind = &h20Not used.
kLSRequestExtensionFlagsOnly= &h40Requests only the kLSItemInfoExtensionIsHidden item-information flag.
kLSRequestAllInfo = -1
LaunchServicesKindStringForCFURLMBS(cfurlhandle as integer) as string
global method, Launch Services, MBS MacOSX Plugin (LaunchServices), Console safe, Plugin version: 3.2, Mac OS X: Works, Windows: Does nothing, Linux x86: Does nothing, Feedback.

Function: Get the kind string for an item.
Notes:
Returns the kind string as used in the Finder and elsewhere for the given folderitem.

Cfurlhandle should be the non 0 value from a CFURL object handle property.
LaunchServicesOpenMBS(item as folderitem) as folderitem
global method, Launch Services, MBS MacOSX Plugin (LaunchServices), Console safe, Plugin version: 3.2, Mac OS X: Works, Windows: Does nothing, Linux x86: Does nothing, Feedback.

Function: Open an application, document, or folder.
Notes:
Opens applications, documents, and folders. Applications are opened via an 'oapp' or 'rapp' event. Documents are opened in their user-overridden or default applications as appropriate. Folders are opened in the Finder. Use the more specific LaunchServicesOpenXMBS for more control over launching.

Returns a folderitem to the application which was launched.
LaunchServicesOpenXMBS(documents() as folderitem, parameter as LaunchServicesLaunchParameterMBS) as folderitem
global method, Launch Services, MBS MacOSX Plugin (LaunchServices), Console safe, Plugin version: 3.2, Mac OS X: Works, Windows: Does nothing, Linux x86: Does nothing, Feedback.

Function: Opens an application or one or more documents or folders.
Example:
// Open a file in Preview (Mac OS X).
Sub OpenWithPreview(f as folderitem)
dim p as FolderItem
dim d(0) as FolderItem
dim r as FolderItem
dim param as LaunchServicesLaunchParameterMBS

// Find preview
p=LaunchServicesFindApplicationForInfoMBS("prvw","com.apple.Preview","Preview.app")

if p<>Nil then
d(0)=f

param=new LaunchServicesLaunchParameterMBS
param.Application=p
param.Defaults=true // just default settings

r=LaunchServicesOpenXMBS(d, param)
if r<>nil then
Return //Success
end if
end if

// On failure, just launch normally:
f.Launch true
End Sub

Sub Open()
dim f as FolderItem

f=DesktopFolder.Child("1505.jpg")

OpenWithPreview f

End Sub

Notes:
Opens applications, documents, and folders. Applications are opened via an 'oapp' or 'rapp' event. Documents are opened in their user-overridden or default applications as appropriate. Folders are opened in the Finder. Use the more specific LSOpenFromURLSpec for more control over launching.

Returns a folderitem to the application which was launched.
Currently this function is not available to RB versions before 3.5.
Note that the documents parameter is an array of folderitem and not just one.
LaunchServicesSetDefaultHandlerForURLSchemeMBS(URLScheme as string, BundleID as string) as integer
global method, Launch Services, MBS MacOSX Plugin (LaunchServicesCF), Console safe, Plugin version: 6.1, Mac OS X: Works, Windows: Does nothing, Linux x86: Does nothing, Feedback.

Function: Sets the user's preferred handler for the specified URL scheme.
Example:
dim e as integer
dim old as string

old=LaunchServicesDefaultHandlerForURLSchemeMBS("http")

MsgBox "Before: "+old

e=LaunchServicesrbSetDefaultHandlerForURLSchemeMBS("http","com.microsoft.explorer")

MsgBox "LaunchServicesSetDefaultHandlerForURLSchemeMBS: "+str(e)

MsgBox "Between: "+LaunchServicesDefaultHandlerForURLSchemeMBS("http")

e=LaunchServicesrbSetDefaultHandlerForURLSchemeMBS("http",old)

MsgBox "LaunchServicesSetDefaultHandlerForURLSchemeMBS: "+str(e)

MsgBox "After: "+LaunchServicesDefaultHandlerForURLSchemeMBS("http")

Notes:
Returns Mac OS error code with 0 for success.
The handler is specified as an application bundle identifier.
Requires Mac OS X 10.4 to work correct. Returns always -1 on older systems.
LaunchServicesSetDefaultRoleHandlerForContentTypeMBS(ContentType as string, role as integer, BundleID as string) as integer
global method, Launch Services, MBS MacOSX Plugin (LaunchServicesCF), Console safe, Plugin version: 6.0, Mac OS X: Works, Windows: Does nothing, Linux x86: Does nothing, Feedback.

Function: Sets the user's preferred handler for the specified content type (UTI) in the specified role(s).
Example:
dim e as integer

// makes Acrobat the default pdf reader
'e=LaunchServicesSetDefaultRoleHandlerForContentTypeMBS("com.adobe.pdf",-1,"com.adobe.Reader")

// makes preview the default pdf reader
e=LaunchServicesSetDefaultRoleHandlerForContentTypeMBS("com.adobe.pdf",-1,"com.apple.preview")

msgbox str(e)

Notes:
For all roles, specify kLSRolesAll. The handler is specified as an application bundle identifier.
Returns a Mac OS error code or -1 if the function is not available.
Requires Mac OS X 10.4.

Constants you can use for the role parameter:
kLSRolesNone = 1no claim is made about support for this type/scheme
kLSRolesViewer= 2claim to be able to view this type/scheme
kLSRolesEditor= 4claim to be able to edit this type/scheme
kLSRolesAll = -1claim to do it all

Next items

The items on this page are in the following plugins: MBS MacOSX Plugin.