5
// Michael Hutchinson <mhutchinson@novell.com>
7
// Copyright (c) 2010 Novell, Inc.
9
// Permission is hereby granted, free of charge, to any person obtaining a copy
10
// of this software and associated documentation files (the "Software"), to deal
11
// in the Software without restriction, including without limitation the rights
12
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
// copies of the Software, and to permit persons to whom the Software is
14
// furnished to do so, subject to the following conditions:
16
// The above copyright notice and this permission notice shall be included in
17
// all copies or substantial portions of the Software.
19
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
28
using System.Runtime.InteropServices;
30
namespace OSXIntegration.Framework
32
// http://developer.apple.com/mac/library/documentation/Carbon/Reference/Component_Manager/Reference/reference.html
34
static class ComponentManager
36
[DllImport (Carbon.CarbonLib)]
37
public static extern ComponentInstance OpenDefaultComponent (OSType componentType, OSType componentSubType);
39
[DllImport (Carbon.CarbonLib)]
40
public static extern ComponentErr CloseComponent (ComponentInstance componentInstance);
42
[DllImport (Carbon.CarbonLib)]
43
public static extern int GetComponentInstanceError (ComponentInstance componentInstance); //returns an oserr
46
struct ComponentInstance {
49
get { return Handle == IntPtr.Zero; }
53
enum ComponentResult : long
55
InvalidComponentId = -3000,
56
ValidInstancesExist = -3001,
57
ComponentNotCaptured = -3002,
58
ComponentDontRegister = -3003,
59
UnresolvedComponentDll = -3004,
60
RetryComponentRegistration =-3005,
61
BadComponentSelector = 0x80008002,
62
BadComponentInstance = 0x80008001
65
enum ComponentErr : int //this is an OSErr
67
InvalidComponentId = -3000,
68
ValidInstancesExist = -3001,
69
ComponentNotCaptured = -3002,
70
ComponentDontRegister = -3003,
71
UnresolvedComponentDll = -3004,
72
RetryComponentRegistration =-3005,
73
BadComponentSelector = -32766, // 0x80008002,
74
BadComponentInstance = -32767, //0x80008001
78
enum DefaultComponent {
83
AnyFlagsAnyManufacturer = (AnyFlags & AnyManufacturer),
84
AnyFlagsAnyManufacturerAnySubType = (AnyFlags & AnyManufacturer & AnySubType)
87
enum ComponentRequest {
94
UnregisterSelect = -7,
95
GetMPWorkFunctionSelect = -8,
96
ExecuteWiredActionSelect = -9,
97
GetPublicResourceSelect = -10