ObjFW  Check-in [710622bc64]

Overview
Comment:OFWindowsRegistryKey: Add convenience methods
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 710622bc6471145387560554ebcf6a7875ecb49b2c3ce1f8f7b349fd794fdbb5
User & Date: js on 2018-07-10 21:09:36
Other Links: manifest | tags
Context
2018-07-10
21:24
OFDNSResolver: Win32: Get hosts path from registry check-in: 4b20f0e12c user: js tags: trunk
21:09
OFWindowsRegistryKey: Add convenience methods check-in: 710622bc64 user: js tags: trunk
20:44
OFWindowsRegistryKey: Allow retrieving the type check-in: e8ae6a2ca1 user: js tags: trunk
Changes

Modified src/OFWindowsRegistryKey.h from [277603e273] to [01452ba249].

69
70
71
72
73
74
75












76
77
78
79
80
81
82
83
84
85
86
87
88
89
90













91

92
93
94
95

96
97
98
99
100
101
102
103
104
105










106
107
108
109
110
111
112

- (instancetype)init OF_UNAVAILABLE;

/*!
 * @brief Opens the sub key at the specified path.
 *
 * @param path The path of the sub key to open












 * @param options Please refer to the `RegOpenKeyEx()` documentation
 * @param securityAndAccessRights Please refer to the `RegOpenKeyEx()`
 *				  documentation
 * @return The sub key with the specified path, or nil if it does not exist
 */
- (nullable OFWindowsRegistryKey *)
	 openSubKeyWithPath: (OFString *)path
		    options: (DWORD)options
    securityAndAccessRights: (REGSAM)securityAndAccessRights;

/*!
 * @brief Creates a sub key at the specified path or opens it if it already
 *	  exists.
 *
 * @param path The path of the sub key to create













 * @param options Please refer to the `RegCreateKeyEx()` documentation

 * @param securityAndAccessRights Please refer to the `RegCreateKeyEx()`
 *				  documentation
 * @param securityAttributes Please refer to the `RegCreateKeyEx()`
 *			     documentation

 * @param disposition Please refer to the `RegCreateKeyEx()` documentation
 * @return The sub key with the specified path
 */
- (OFWindowsRegistryKey *)
       createSubKeyWithPath: (OFString *)path
		    options: (DWORD)options
    securityAndAccessRights: (REGSAM)securityAndAccessRights
	 securityAttributes: (nullable LPSECURITY_ATTRIBUTES)securityAttributes
		disposition: (nullable LPDWORD)disposition;











/*!
 * @brief Returns the string for the specified value at the specified path.
 *
 * @param value The name of the value to return
 * @param subKeyPath The path of the key from which to retrieve the value
 * @param flags Extra flags for `RegGetValue()`. Usually 0.
 * @param type A pointer to store the type of the value, or NULL







>
>
>
>
>
>
>
>
>
>
>
>
|














>
>
>
>
>
>
>
>
>
>
>
>
>
|
>



|
>
|









>
>
>
>
>
>
>
>
>
>







69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
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

- (instancetype)init OF_UNAVAILABLE;

/*!
 * @brief Opens the sub key at the specified path.
 *
 * @param path The path of the sub key to open
 * @param securityAndAccessRights Please refer to the `RegOpenKeyEx()`
 *				  documentation
 * @return The sub key with the specified path, or nil if it does not exist
 */
- (nullable OFWindowsRegistryKey *)
	 openSubKeyWithPath: (OFString *)path
    securityAndAccessRights: (REGSAM)securityAndAccessRights;

/*!
 * @brief Opens the sub key at the specified path.
 *
 * @param path The path of the sub key to open
 * @param options Please refer to the `RegOpenKeyEx()` documentation. Usually 0.
 * @param securityAndAccessRights Please refer to the `RegOpenKeyEx()`
 *				  documentation
 * @return The sub key with the specified path, or nil if it does not exist
 */
- (nullable OFWindowsRegistryKey *)
	 openSubKeyWithPath: (OFString *)path
		    options: (DWORD)options
    securityAndAccessRights: (REGSAM)securityAndAccessRights;

/*!
 * @brief Creates a sub key at the specified path or opens it if it already
 *	  exists.
 *
 * @param path The path of the sub key to create
 * @param securityAndAccessRights Please refer to the `RegCreateKeyEx()`
 *				  documentation
 * @return The sub key with the specified path
 */
- (OFWindowsRegistryKey *)
       createSubKeyWithPath: (OFString *)path
    securityAndAccessRights: (REGSAM)securityAndAccessRights;

/*!
 * @brief Creates a sub key at the specified path or opens it if it already
 *	  exists.
 *
 * @param path The path of the sub key to create
 * @param options Please refer to the `RegCreateKeyEx()` documentation.
 *		  Usually 0.
 * @param securityAndAccessRights Please refer to the `RegCreateKeyEx()`
 *				  documentation
 * @param securityAttributes Please refer to the `RegCreateKeyEx()`
 *			     documentation. Usually NULL.
 * @param disposition Whether the key was created or already existed. Please
 *		      refer to the `RegCreateKeyEx()` documentation.
 * @return The sub key with the specified path
 */
- (OFWindowsRegistryKey *)
       createSubKeyWithPath: (OFString *)path
		    options: (DWORD)options
    securityAndAccessRights: (REGSAM)securityAndAccessRights
	 securityAttributes: (nullable LPSECURITY_ATTRIBUTES)securityAttributes
		disposition: (nullable LPDWORD)disposition;

/*!
 * @brief Returns the string for the specified value at the specified path.
 *
 * @param value The name of the value to return
 * @param subKeyPath The path of the key from which to retrieve the value
 * @return The string for the specified value
 */
- (nullable OFString *)stringForValue: (nullable OFString *)value
			   subKeyPath: (nullable OFString *)subKeyPath;

/*!
 * @brief Returns the string for the specified value at the specified path.
 *
 * @param value The name of the value to return
 * @param subKeyPath The path of the key from which to retrieve the value
 * @param flags Extra flags for `RegGetValue()`. Usually 0.
 * @param type A pointer to store the type of the value, or NULL

Modified src/OFWindowsRegistryKey.m from [1ce505ad65] to [b87f081cd6].

80
81
82
83
84
85
86








87
88
89
90
91
92
93
- (void)dealloc
{
	if (_close)
		RegCloseKey(_hKey);

	[super dealloc];
}









- (OFWindowsRegistryKey *)openSubKeyWithPath: (OFString *)path
				     options: (DWORD)options
		     securityAndAccessRights: (REGSAM)securityAndAccessRights
{
	void *pool = objc_autoreleasePoolPush();
	LSTATUS status;







>
>
>
>
>
>
>
>







80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
- (void)dealloc
{
	if (_close)
		RegCloseKey(_hKey);

	[super dealloc];
}

- (OFWindowsRegistryKey *)openSubKeyWithPath: (OFString *)path
		     securityAndAccessRights: (REGSAM)securityAndAccessRights
{
	return [self openSubKeyWithPath: path
				options: 0
		securityAndAccessRights: securityAndAccessRights];
}

- (OFWindowsRegistryKey *)openSubKeyWithPath: (OFString *)path
				     options: (DWORD)options
		     securityAndAccessRights: (REGSAM)securityAndAccessRights
{
	void *pool = objc_autoreleasePoolPush();
	LSTATUS status;
110
111
112
113
114
115
116











117
118
119
120
121
122
123

	objc_autoreleasePoolPop(pool);

	return [[[OFWindowsRegistryKey alloc] of_initWithHKey: subKey
							close: true]
	    autorelease];
}












- (OFWindowsRegistryKey *)
       createSubKeyWithPath: (OFString *)path
		    options: (DWORD)options
    securityAndAccessRights: (REGSAM)securityAndAccessRights
	 securityAttributes: (LPSECURITY_ATTRIBUTES)securityAttributes
		disposition: (LPDWORD)disposition







>
>
>
>
>
>
>
>
>
>
>







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

	objc_autoreleasePoolPop(pool);

	return [[[OFWindowsRegistryKey alloc] of_initWithHKey: subKey
							close: true]
	    autorelease];
}

- (OFWindowsRegistryKey *)
       createSubKeyWithPath: (OFString *)path
    securityAndAccessRights: (REGSAM)securityAndAccessRights
{
	return [self createSubKeyWithPath: path
				  options: 0
		  securityAndAccessRights: securityAndAccessRights
		       securityAttributes: NULL
			      disposition: NULL];
}

- (OFWindowsRegistryKey *)
       createSubKeyWithPath: (OFString *)path
		    options: (DWORD)options
    securityAndAccessRights: (REGSAM)securityAndAccessRights
	 securityAttributes: (LPSECURITY_ATTRIBUTES)securityAttributes
		disposition: (LPDWORD)disposition
139
140
141
142
143
144
145









146
147
148
149
150
151
152

	objc_autoreleasePoolPop(pool);

	return [[[OFWindowsRegistryKey alloc] of_initWithHKey: subKey
							close: true]
	    autorelease];
}










- (OFString *)stringForValue: (OFString *)value
		  subKeyPath: (OFString *)subKeyPath
		       flags: (DWORD)flags
			type: (LPDWORD)type
{
	void *pool = objc_autoreleasePoolPush();







>
>
>
>
>
>
>
>
>







158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180

	objc_autoreleasePoolPop(pool);

	return [[[OFWindowsRegistryKey alloc] of_initWithHKey: subKey
							close: true]
	    autorelease];
}

- (OFString *)stringForValue: (OFString *)value
		  subKeyPath: (OFString *)subKeyPath
{
	return [self stringForValue: value
			 subKeyPath: subKeyPath
			      flags: 0
			       type: NULL];
}

- (OFString *)stringForValue: (OFString *)value
		  subKeyPath: (OFString *)subKeyPath
		       flags: (DWORD)flags
			type: (LPDWORD)type
{
	void *pool = objc_autoreleasePoolPush();