89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
|
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
|
-
+
-
-
-
-
-
-
-
-
-
+
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
+
+
+
+
-
-
+
+
-
+
-
-
-
+
+
|
if (_close)
RegCloseKey(_hKey);
[super dealloc];
}
- (OFWindowsRegistryKey *)openSubkeyAtPath: (OFString *)path
securityAndAccessRights: (REGSAM)securityAndAccessRights
accessRights: (REGSAM)accessRights
{
return [self openSubkeyAtPath: path
options: 0
securityAndAccessRights: securityAndAccessRights];
}
- (OFWindowsRegistryKey *)openSubkeyAtPath: (OFString *)path
options: (DWORD)options
securityAndAccessRights: (REGSAM)securityAndAccessRights
{
void *pool = objc_autoreleasePoolPush();
LSTATUS status;
HKEY subKey;
if ([OFSystemInfo isWindowsNT])
status = RegOpenKeyExW(_hKey, path.UTF16String, options,
securityAndAccessRights, &subKey);
accessRights, &subKey);
else
status = RegOpenKeyExA(_hKey,
[path cStringWithEncoding: [OFLocale encoding]], options,
securityAndAccessRights, &subKey);
accessRights, &subKey);
if (status != ERROR_SUCCESS)
@throw [OFOpenWindowsRegistryKeyFailedException
exceptionWithRegistryKey: self
path: path
accessRights: accessRights
options: options
securityAndAccessRights: securityAndAccessRights
status: status];
objc_autoreleasePoolPop(pool);
return [[[OFWindowsRegistryKey alloc] of_initWithHKey: subKey
close: true]
autorelease];
}
- (OFWindowsRegistryKey *)createSubkeyAtPath: (OFString *)path
securityAndAccessRights: (REGSAM)securityAndAccessRights
{
return [self createSubkeyAtPath: path
options: 0
securityAndAccessRights: securityAndAccessRights
securityAttributes: NULL
disposition: NULL];
}
- (OFWindowsRegistryKey *)
createSubkeyAtPath: (OFString *)path
createSubkeyAtPath: (OFString *)path
options: (DWORD)options
securityAndAccessRights: (REGSAM)securityAndAccessRights
securityAttributes: (LPSECURITY_ATTRIBUTES)securityAttributes
disposition: (DWORD *)disposition
accessRights: (REGSAM)accessRights
securityAttributes: (LPSECURITY_ATTRIBUTES)securityAttributes
options: (DWORD)options
disposition: (DWORD *)disposition
{
void *pool = objc_autoreleasePoolPush();
LSTATUS status;
HKEY subKey;
if ([OFSystemInfo isWindowsNT])
status = RegCreateKeyExW(_hKey, path.UTF16String, 0,
NULL, options, securityAndAccessRights, securityAttributes,
&subKey, NULL);
NULL, options, accessRights, securityAttributes, &subKey,
NULL);
else
status = RegCreateKeyExA(_hKey,
[path cStringWithEncoding: [OFLocale encoding]], 0, NULL,
options, securityAndAccessRights, securityAttributes,
options, accessRights, securityAttributes, &subKey, NULL);
&subKey, NULL);
if (status != ERROR_SUCCESS)
@throw [OFCreateWindowsRegistryKeyFailedException
exceptionWithRegistryKey: self
path: path
options: options
securityAndAccessRights: securityAndAccessRights
accessRights: accessRights
securityAttributes: securityAttributes
options: options
status: status];
objc_autoreleasePoolPop(pool);
return [[[OFWindowsRegistryKey alloc] of_initWithHKey: subKey
close: true]
autorelease];
|