use of org.jinterop.winreg.JIPolicyHandle in project hudson-2.x by hudson.
the class DotNet method isInstalled.
/**
* Returns true if the .NET framework of the given version (or grater) is installed
* on a remote machine.
*/
public static boolean isInstalled(int major, int minor, String targetMachine, IJIAuthInfo session) throws JIException, UnknownHostException {
IJIWinReg registry = JIWinRegFactory.getSingleTon().getWinreg(session, targetMachine, true);
JIPolicyHandle hklm = null;
JIPolicyHandle key = null;
try {
hklm = registry.winreg_OpenHKLM();
key = registry.winreg_OpenKey(hklm, "SOFTWARE\\Microsoft\\.NETFramework", IJIWinReg.KEY_READ);
for (int i = 0; ; i++) {
String keyName = registry.winreg_EnumKey(key, i)[0];
if (matches(keyName, major, minor))
return true;
}
} catch (JIException e) {
if (e.getErrorCode() == 2)
// not found
return false;
throw e;
} finally {
if (hklm != null)
registry.winreg_CloseKey(hklm);
if (key != null)
registry.winreg_CloseKey(key);
registry.closeConnection();
}
}
Aggregations