mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-16 13:32:24 +00:00
valueExists use the same code as getValue
This commit is contained in:
1 parent
8d1cda0edd
commit
4e7220c924
1 file changed
+20
-8
@@ -156,14 +156,26 @@ public class RegistryKey {
|
||||
* Does a specified value exist?
|
||||
*/
|
||||
public boolean valueExists(String name) {
|
||||
int r = Advapi32.INSTANCE.RegQueryValueEx(handle, name, null, new IntByReference(), new byte[1], new IntByReference());
|
||||
switch(r) {
|
||||
case WINERROR.ERROR_FILE_NOT_FOUND:
|
||||
return false;
|
||||
case WINERROR.ERROR_SUCCESS:
|
||||
return true;
|
||||
default:
|
||||
throw new JnaException(r);
|
||||
IntByReference pType, lpcbData;
|
||||
byte[] lpData = new byte[1];
|
||||
|
||||
pType = new IntByReference();
|
||||
lpcbData = new IntByReference();
|
||||
|
||||
OUTER:
|
||||
while(true) {
|
||||
int r = Advapi32.INSTANCE.RegQueryValueEx(handle, name, null, pType, lpData, lpcbData);
|
||||
switch(r) {
|
||||
case WINERROR.ERROR_MORE_DATA:
|
||||
lpData = new byte[lpcbData.getValue()];
|
||||
continue OUTER;
|
||||
case WINERROR.ERROR_FILE_NOT_FOUND:
|
||||
return false;
|
||||
case WINERROR.ERROR_SUCCESS:
|
||||
return true;
|
||||
default:
|
||||
throw new JnaException(r);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user